import { Component } from 'react';

import { Boxs, List,Tab,SearchBar,Button,Group,Avatar,Popup,Dialog,Toast } from 'saltui';

const { HBox, Box,VBox } = Boxs;
import { nodataIcon } from '../../app/variables';
import './select.less';
import utils from './utils';
import 'whatwg-fetch';
import 'es6-promise';

export default class Page extends Component {
  constructor(props) {
    super(props);

    var winHeight = parseInt(getScrollHigh(0, 0, 0));
    var token = document.getElementById('token').value;
    //var baseContext = document.getElementById('baseContext').value;
	var context = getLoginUserInfo().context;

    this.state = {
      label: props.label,
      required: props.required,
      isDelete: props.isDelete,
      readOnly: props.readOnly,
      showType: props.showType,
      placeholder: props.placeholder,
      queryLimit: props.queryLimit,
      limitData: props.limitData,
      chooseType: "",

      isShowNav: false,//是否展示面包屑导航
      isShowCheckAll: false,//是否展示全选
      commonCheckAll: false,//常用是否全选
      navUserList: [],//面包屑导航list
      navOrgList: [],//面包屑导航list
      roleCheckAll: false,//角色是否全选
      navStationList: [],//面包屑导航list
      navGroupList: [],//群组是否全选
      isSelectShow: false,//是否是已选查看页
      staSelectType: "0",
      activeKey: 'user',
      commonUsedData: [],
      commonDefaultData: [],
      userOrgList: [],
      userList: [],
      orgList: [],
      orgUserList: [],
      roleList: [],
      stationList: [],
      stationOrgList: [],
      groupList: [],
      groupUserList: [],
      total: 0,//选中总数
      selectCommonNum: 0,
      selectUserNum: 0,
      selectOrgNum: 0,
      selectOrgUserNum: 0,
      selectRoleNum: 0,
      selectStaNum: 0,
      selectGroupNum: 0,
      selectGroupUserNum: 0,
      noUseOrgNum: 0,//不可选部门数量
      noUseStationNum: 0,
      noUseGroupNum: 0,
      commonName: "",
      userName: "",
      orgName: "",
      roleName: "",
      stationName: "",
      groupName: "",
      selectedList: {selectUsers:[], selectOrgs:[], selectRoles:[], selectStations:[], selectGroups:[]},
      defaultList: [],
      scopeList: [],
      token: token,
      context: context,
      winHeight: winHeight+"px",
      tabHeight: "",
      top: ""
    };

    this.listener = this.handleHidePopup.bind(this);
  }

  //去除监听并关闭弹出页
  handleHidePopup(e) {
    const { state } = e;
    if (!state || !state.SelectMember || state.SelectMember !== this.state.historyStamp) {
      const t = this;
      t.cancelOrBack();
      window.removeEventListener('popstate', t.listener, false);
      $("#App").css({
        "overflow":"auto",
        "height":"",
      });
      var top = t.state.top;
      Popup.hide();
      setTimeout(function(){
        $(window).scrollTop(top);
      });
    }
  }

  scopeListToSelectList(scopeLists, defaultList){
    var selectedList = {};
    var selectUsers = [], selectOrgs = [], selectRoles = [], selectStations = [],selectGroups = [];
    for(var i=0; i<scopeLists.length;i++){
      var scope = scopeLists[i];
      if(defaultList != null){
        defaultList.push(scope);
      }
      if(scope.scopeType == "user"){
        var user = {
          "id": scope.scopeValue,
          "userName": scope.scopeName,
          "imageId": scope.imageId
        };
        selectUsers.push(user);
      }else if(scope.scopeType == "org"){
        var org = {
          "id": scope.scopeValue,
          "orgName": scope.scopeName,
		  "orgType": scope.orgType
        };
        selectOrgs.push(org);
      }else if(scope.scopeType == "role"){
        var role = {
          "id": scope.scopeValue,
          "roleName": scope.scopeName
        };
        selectRoles.push(role);
      }else if(scope.scopeType == "station"){
        var station = {
          "id": scope.scopeValue,
          "stationName": scope.scopeName
        };
        selectStations.push(station);
      }else if(scope.scopeType == "group"){
        var group = {
          "id": scope.scopeValue,
          "groupName": scope.scopeName
        };
        selectGroups.push(group);
      }
    }
    selectedList.selectUsers = selectUsers;
    selectedList.selectOrgs = selectOrgs;
    selectedList.selectRoles = selectRoles;
    selectedList.selectStations = selectStations;
    selectedList.selectGroups = selectGroups;
    return selectedList;
  }

  //判断code
  getRealCode(){
    var code = this.props.code;
	code = "," + code + ",";
	if(code.indexOf(",inst,")>=0 && code.indexOf(",dep,")>=0){
		code = code.replace(",inst,", ",org,");
		code = code.replace(",dep,", ",");
	}else if(code.indexOf(",inst,") >= 0){
      code = code.replace(",inst,", ",org,");
    }else if(code.indexOf(",dep,") >= 0){
      code = code.replace(",dep,", ",org,");
    }
	if(code!="" && code!=null && code!=undefined){
		code = code.substring(1, code.length-1);
	}
    return code;
  }

  getOrgType(){
      var code = this.props.code;
      var orgType = "";
	  if(code.indexOf("inst")>=0 && code.indexOf("dep")>=0){
		  orgType = "";
	  }else if(code.indexOf("inst") >= 0){
          orgType = "2"
      }else if(code.indexOf("dep") >= 0){
          orgType = "3";
      }
      return orgType;
  }

  //获取chooseType值
  getChooseType(){
    var chooseType = this.props.chooseType;
    var code = this.getRealCode();
    if(code==null || code==undefined){
      code = "";
    }
    if(chooseType==null || chooseType==undefined || chooseType==""){
      chooseType = "";
      if(code.indexOf("user")>=0 && code.indexOf("org")>=0){
        chooseType = "userAndOrg";
      }else if(code.indexOf("user")>=0 && code.indexOf("org")<0){
        chooseType = "userNotOrg";
      }else if(code.indexOf("user")<0 && code.indexOf("org")>=0){
        chooseType = "org";
      }else{
        chooseType = "";
      }
      if(code.indexOf("group") >= 0){
        if(chooseType == ""){
          chooseType += "group";
        }else{
          chooseType += ",group";
        }
      }else{
        chooseType += "";
      }
    }
    return chooseType;
  }

  //解析传入数据
  initSelectData(){
    var fieldDataValue = this.props.fieldDataValue;
	var t = this;
    if(fieldDataValue!="" && fieldDataValue!=null && fieldDataValue!=undefined){
      var scopeTable = this.props.scopeTable;
      if(scopeTable=="" || scopeTable==null || scopeTable==undefined){
        scopeTable = "cmp_scope";
      }
      var fieldTable = this.props.fieldTable;
      var fieldData = this.props.fieldData;
      var token = this.state.token;
      var url = t.state.context+"/client/cmp/popuser/mobile/getOfficePopuser?token="+token+"&scopeTable="+scopeTable+"&fieldTable="+fieldTable+"&fieldData="+fieldData+"&fieldDataValue="+fieldDataValue;
      fetch(url,{
        method: "GET",
        mode: "cors",
        headers: {
          'Accept': 'application/json, text/plain, */*',
          'Content-Type': 'application/x-www-form-urlencoded'
        }
      }).then((response) => response.json()).then((result) => {//alert(JSON.stringify(result));
        //console.log("fetch请求数据"+JSON.stringify(result));
        var data = result.data;
        if(data!=null && data!=undefined){
          var scopeLists = data.scopeInfoList;
          var defaultList = [];
          var selectedList = t.scopeListToSelectList(scopeLists, defaultList);
          t.setState({
            selectedList: selectedList,
            defaultList: defaultList,
            scopeList: scopeLists,
            total: scopeLists.length
          },()=>{if(t.instance){t.instance.update(t.getContent());}});
          if(t.props.onChange != undefined){
            t.props.onChange(scopeLists,fieldDataValue);
          }
        }
      }).catch((error) => {
        alert("错误："+error);
      });
    }else{
      var defaultValue = this.props.defaultValue;
      if(defaultValue!="" && defaultValue!=null && defaultValue!=undefined){
        var defaultList = [];
        var selectedLists = this.scopeListToSelectList(defaultValue, defaultList);
        this.setState({
          selectedList: selectedLists,
          defaultList: defaultList,
          scopeList: defaultValue,
          total: defaultList.length
        },()=>{if(t.instance){t.instance.update(t.getContent());}});
        if(this.props.onChange != undefined){
          this.props.onChange(defaultValue);
        }
      }
    }
  }

  //全选
  checkAllMember(type){
    const t = this;
    var scopeList = this.state.scopeList;
    var chooseType = this.getChooseType();
    if("user" == type){
      var navList = t.state.navUserList;
      var index = navList.length - 1;
      navList[index].checkAll = !navList[index].checkAll;
      var userList = t.state.userList;
      var total = t.state.total;
      var selectUserNum = t.state.selectUserNum;
      var selectedList = t.state.selectedList;
      var selectUsers = selectedList.selectUsers;
      if(selectUsers==null || selectUsers==undefined){
        selectUsers = [];
      }
      if(navList[index].checkAll){
        for(var i=0; i<userList.length; i++){
          if(!userList[i].checked){
            userList[i].checked = true;
            total ++;
            selectUserNum ++;
          }
          var flag = true;
          for(var j=0; j<selectUsers.length; j++){
            if(selectUsers[j].id == userList[i].id){
              flag = false;
              break;
            }
          }
          if(flag){
            var scope = {
              "scopeType": "user",
              "scopeName": userList[i].userName,
              "scopeValue": userList[i].id
            };
            scopeList.push(scope);
            selectUsers.push(userList[i]);
          }
        }
      }else{
        for(var i=0; i<userList.length; i++){
          if(userList[i].checked){
            userList[i].checked = false;
            total --;
            selectUserNum --;
          }
          for(var j=0; j<selectUsers.length; j++){
            if(selectUsers[j].id == userList[i].id){
              selectUsers.splice(j, 1);
              break;
            }
          }
          for(var j=0; j<scopeList.length; j++){
            if(scopeList[j].scopeValue == userList[i].id){
              scopeList.splice(j, 1);
              break;
            }
          }
        }
      }
      selectedList.selectUsers = selectUsers;
      t.setState({
        userList: userList,
        total: total,
        selectUserNum: selectUserNum,
        navUserList: navList,
        selectedList: selectedList,
        scopeList: scopeList
      },()=>{this.instance.update(this.getContent())});
    }else if("org" == type){
      var navList = t.state.navOrgList;
      var index = navList.length - 1;
      if(navList[index].canUse == "0"){
        return;
      }
      navList[index].checkAll = !navList[index].checkAll;
      var orgList = t.state.orgList;
      var orgUserList = t.state.orgUserList;
      var total = t.state.total;
      var selectOrgNum = t.state.selectOrgNum;
      var selectOrgUserNum = t.state.selectOrgUserNum;
      var selectedList = t.state.selectedList;
      var selectOrgs = selectedList.selectOrgs;
      if(selectOrgs==null || selectOrgs==undefined){
        selectOrgs = [];
      }
      var selectUsers = selectedList.selectUsers;
      if(selectUsers==null || selectUsers==undefined){
        selectUsers = [];
      }
      if(navList[index].checkAll){
        if(chooseType.indexOf("userNotOrg") < 0){
          for(var i=0; i<orgList.length; i++){
            if(orgList[i].canUse == "1"){
              if(!orgList[i].checked){
                orgList[i].checked = true;
                total ++;
                selectOrgNum ++;
              }
              var flag = true;
              for(var j=0; j<selectOrgs.length; j++){
                if(selectOrgs[j].id == orgList[i].id){
                  flag = false;
                  break;
                }
              }
              if(flag){
                var scope = {
                  "scopeType": "org",
                  "scopeName": orgList[i].orgName,
                  "scopeValue": orgList[i].id,
				  "orgType": orgList[i].orgType
                };
                scopeList.push(scope);
                selectOrgs.push(orgList[i]);
              }
            }
          }
        }
        for(var i=0; i<orgUserList.length; i++){
          if(!orgUserList[i].checked){
            orgUserList[i].checked = true;
            total ++;
            selectOrgUserNum ++;
          }
          var flag = true;
          for(var j=0; j<selectUsers.length; j++){
            if(selectUsers[j].id == orgUserList[i].id){
              flag = false;
              break;
            }
          }
          if(flag){
            var scope = {
              "scopeType": "user",
              "scopeName": orgUserList[i].userName,
              "scopeValue": orgUserList[i].id
            };
            scopeList.push(scope);
            selectUsers.push(orgUserList[i]);
          }
        }
      }else{
        if(chooseType.indexOf("userNotOrg") < 0) {
          for (var i = 0; i < orgList.length; i++) {
            if (orgList[i].canUse == "1") {
              if (orgList[i].checked) {
                orgList[i].checked = false;
                total--;
                selectOrgNum--;
              }
              for (var j = 0; j < selectOrgs.length; j++) {
                if (selectOrgs[j].id == orgList[i].id) {
                  selectOrgs.splice(j, 1);
                  break;
                }
              }
              for (var j = 0; j < scopeList.length; j++) {
                if (scopeList[j].scopeValue == orgList[i].id) {
                  scopeList.splice(j, 1);
                  break;
                }
              }
            }
          }
        }
        for(var i=0; i<orgUserList.length; i++){
          if(orgUserList[i].checked){
            orgUserList[i].checked = false;
            total --;
            selectOrgUserNum --;
          }
          for(var j=0; j<selectUsers.length; j++){
            if(selectUsers[j].id == orgUserList[i].id){
              selectUsers.splice(j, 1);
              break;
            }
          }
          for(var j=0; j<scopeList.length; j++){
            if(scopeList[j].scopeValue == orgUserList[i].id){
              scopeList.splice(j, 1);
              break;
            }
          }
        }
      }
      selectedList.selectOrgs = selectOrgs;
      selectedList.selectUsers = selectUsers;
      t.setState({
        orgList: orgList,
        orgUserList: orgUserList,
        total: total,
        selectOrgNum: selectOrgNum,
        selectOrgUserNum: selectOrgUserNum,
        navOrgList: navList,
        selectedList: selectedList,
        scopeList: scopeList
      },()=>{this.instance.update(this.getContent())});
    }else if("role" == type){
      var roleCheckAll = t.state.roleCheckAll;
      roleCheckAll = !roleCheckAll;
      var roleList = t.state.roleList;
      var total = t.state.total;
      var selectRoleNum = t.state.selectRoleNum;
      var selectedList = t.state.selectedList;
      var selectRoles = selectedList.selectRoles;
      if(selectRoles==null || selectRoles==undefined){
        selectRoles = [];
      }
      if(roleCheckAll){
        for(var i=0; i<roleList.length; i++){
          if(!roleList[i].checked){
            roleList[i].checked = true;
            total ++;
            selectRoleNum ++;
          }
          var flag = true;
          for(var j=0; j<selectRoles.length; j++){
            if(selectRoles[j].id == roleList[i].id){
              flag = false;
              break;
            }
          }
          if(flag){
            var scope = {
              "scopeType": "role",
              "scopeName": roleList[i].roleName,
              "scopeValue": roleList[i].id
            };
            scopeList.push(scope);
            selectRoles.push(roleList[i]);
          }
        }
      }else{
        for(var i=0; i<roleList.length; i++){
          if(roleList[i].checked){
            roleList[i].checked = false;
            total --;
            selectRoleNum --;
          }
          for(var j=0; j<selectRoles.length; j++){
            if(selectRoles[j].id == roleList[i].id){
              selectRoles.splice(j, 1);
              break;
            }
          }
          for(var j=0; j<scopeList.length; j++){
            if(scopeList[j].scopeValue == roleList[i].id){
              scopeList.splice(j, 1);
              break;
            }
          }
        }
      }
      selectedList.selectRoles = selectRoles;
      t.setState({
        roleList: roleList,
        total: total,
        selectRoleNum: selectRoleNum,
        roleCheckAll: roleCheckAll,
        selectedList: selectedList,
        scopeList: scopeList
      },()=>{this.instance.update(this.getContent())});
    }else if("station" == type){
      var navList = t.state.navStationList;
      var index = navList.length - 1;
      if(navList[index].canUse == "0"){
        return;
      }
      navList[index].checkAll = !navList[index].checkAll;
      var stationList = t.state.stationList;
      var total = t.state.total;
      var selectStaNum = t.state.selectStaNum;
      var selectedList = t.state.selectedList;
      var selectStations = selectedList.selectStations;
      if(selectStations==null || selectStations==undefined){
        selectStations = [];
      }
      if(navList[index].checkAll){
        for(var i=0; i<stationList.length; i++){
          if(stationList[i].canUse == "1"){
            if(!stationList[i].checked){
              stationList[i].checked = true;
              total ++;
              selectStaNum ++;
            }
            var flag = true;
            for(var j=0; j<selectStations.length; j++){
              if(selectStations[j].id == stationList[i].id){
                flag = false;
                break;
              }
            }
            if(flag){
              var scope = {
                "scopeType": "station",
                "scopeName": stationList[i].stationName,
                "scopeValue": stationList[i].id
              };
              scopeList.push(scope);
              selectStations.push(stationList[i]);
            }
          }
        }
      }else{
        for(var i=0; i<stationList.length; i++){
          if(stationList[i].canUse == "1"){
            if(stationList[i].checked){
              stationList[i].checked = false;
              total --;
              selectStaNum --;
            }
            for(var j=0; j<selectStations.length; j++){
              if(selectStations[j].id == stationList[i].id){
                selectStations.splice(j, 1);
                break;
              }
            }
            for(var j=0; j<scopeList.length; j++){
              if(scopeList[j].scopeValue == stationList[i].id){
                scopeList.splice(j, 1);
                break;
              }
            }
          }
        }
      }
      selectedList.selectStations = selectStations;
      t.setState({
        stationList: stationList,
        total: total,
        selectStaNum: selectStaNum,
        navStationList: navList,
        selectedList: selectedList,
        scopeList: scopeList
      },()=>{this.instance.update(this.getContent())});
    }else if("group" == type){
      var navList = t.state.navGroupList;
      var index = navList.length - 1;
      if(navList[index].canUse == "0"){
        return;
      }
      navList[index].checkAll = !navList[index].checkAll;
      var groupList = t.state.groupList;
      var groupUserList = t.state.groupUserList;
      var total = t.state.total;
      var selectGroupNum = t.state.selectGroupNum;
      var selectGroupUserNum = t.state.selectGroupUserNum;
      var selectedList = t.state.selectedList;
      var selectGroups = selectedList.selectGroups;
      if(selectGroups==null || selectGroups==undefined){
        selectGroups = [];
      }
      var selectUsers = selectedList.selectUsers;
      if(selectUsers==null || selectUsers==undefined){
        selectUsers = [];
      }
      if(navList[index].checkAll){
        if(chooseType.indexOf("userNotGroup") < 0) {
          for (var i = 0; i < groupList.length; i++) {
            if (groupList[i].canUse == "1") {
              if (!groupList[i].checked) {
                groupList[i].checked = true;
                total++;
                selectGroupNum++;
              }
              var flag = true;
              for (var j = 0; j < selectGroups.length; j++) {
                if (selectGroups[j].id == groupList[i].id) {
                  flag = false;
                  break;
                }
              }
              if (flag) {
                var scope = {
                  "scopeType": "group",
                  "scopeName": groupList[i].groupName,
                  "scopeValue": groupList[i].id
                };
                scopeList.push(scope);
                selectGroups.push(groupList[i]);
              }
            }
          }
        }
        for(var i=0; i<groupUserList.length; i++){
          if(!groupUserList[i].checked){
            groupUserList[i].checked = true;
            total ++;
            selectGroupUserNum ++;
          }
          var flag = true;
          for(var j=0; j<selectUsers.length; j++){
            if(selectUsers[j].id == groupUserList[i].id){
              flag = false;
              break;
            }
          }
          if(flag){
            var scope = {
              "scopeType": "user",
              "scopeName": groupUserList[i].userName,
              "scopeValue": groupUserList[i].id
            };
            scopeList.push(scope);
            selectUsers.push(groupUserList[i]);
          }
        }
      }else{
        if(chooseType.indexOf("userNotOrg") < 0) {
          for (var i = 0; i < groupList.length; i++) {
            if (groupList[i].canUse == "1") {
              if (groupList[i].checked) {
                groupList[i].checked = false;
                total--;
                selectGroupNum--;
              }
              for (var j = 0; j < selectGroups.length; j++) {
                if (selectGroups[j].id == groupList[i].id) {
                  selectGroups.splice(j, 1);
                  break;
                }
              }
              for (var j = 0; j < scopeList.length; j++) {
                if (scopeList[j].scopeValue == groupList[i].id) {
                  scopeList.splice(j, 1);
                  break;
                }
              }
            }
          }
        }
        for(var i=0; i<groupUserList.length; i++){
          if(groupUserList[i].checked){
            groupUserList[i].checked = false;
            total --;
            selectGroupUserNum --;
          }
          for(var j=0; j<selectUsers.length; j++){
            if(selectUsers[j].id == groupUserList[i].id){
              selectUsers.splice(j, 1);
              break;
            }
          }
          for(var j=0; j<scopeList.length; j++){
            if(scopeList[j].scopeValue == groupUserList[i].id){
              scopeList.splice(j, 1);
              break;
            }
          }
        }
      }
      selectedList.selectGroups = selectGroups;
      selectedList.selectUsers = selectUsers;
      t.setState({
        groupList: groupList,
        groupUserList: groupUserList,
        total: total,
        selectGroupNum: selectGroupNum,
        selectGroupUserNum: selectGroupUserNum,
        navGroupList: navList,
        selectedList: selectedList,
        scopeList: scopeList
      },()=>{this.instance.update(this.getContent())});
    }
  }

  //获取URL
  getFetchUrl(type, id, search, isOrgChild, isLimit){
    var context = this.state.context;
    var token = this.state.token;
    var searchLimit = "";
    var queryLimit = this.props.queryLimit;
    var limitData = this.props.limitData;
    if(isLimit && queryLimit!="" && queryLimit!=undefined){
      searchLimit = "&queryLimit="+queryLimit+"&limitData="+limitData;
    }
    var chooseType = this.getChooseType();
    var url = "";
    var orgType = this.getOrgType();
    if(type == "org"){
      if(chooseType.indexOf("userNotOrg")<0 && chooseType.indexOf("userAndOrg")<0){
        url = context+"/client/cmp/popuser/mobile/getPopuOrgInfo?token="+token+"&orgId="+id+"&orgName="+search+"&corpId="+realCorpId+searchLimit+"&orgType="+orgType;
      }else{
        if(isOrgChild){
          url = context+"/client/cmp/popuser/mobile/getPopuOrgChildInfo?token="+token+"&orgId="+id+"&searchData="+search+"&type=user&corpId="+realCorpId+searchLimit+"&orgType="+orgType;
        }else{
          url = context+"/client/cmp/popuser/mobile/getPopuOrgInfo?token="+token+"&orgId="+id+"&orgName="+search+"&corpId="+realCorpId+searchLimit+"&orgType="+orgType;
        }
      }
    }else if(type == "user"){
      if(isOrgChild){
        url = context+"/client/cmp/popuser/mobile/getPopuOrgChildInfo?token="+token+"&orgId="+id+"&type="+type+"&corpId="+realCorpId+searchLimit+"&orgType="+orgType;
      }else{
        url = context+"/client/cmp/popuser/mobile/getPopuUserInfo?token="+token+"&userName="+search+"&corpId="+realCorpId+searchLimit;
      }
    }else if(type == "station"){
      if(isOrgChild){
        url = context+"/client/cmp/popuser/mobile/getPopuOrgChildInfo?token="+token+"&orgId="+id+"&type="+type+"&corpId="+realCorpId+searchLimit+"&orgType="+orgType;
      }else{
        url = context+"/client/cmp/popuser/mobile/getPopuStationInfo?token="+token+"&stationId="+id+"&stationName="+search+"&corpId="+realCorpId+searchLimit;
      }
    }else if(type == "group"){
      if(chooseType.indexOf("userNotGroup")<0 && chooseType.indexOf("userAndGroup")<0){
        url = context+"/client/cmp/popuser/mobile/getPopuGroupInfo?token="+token+"&groupId="+id+"&type=group"+"&searchData="+search+"&corpId="+realCorpId+searchLimit;
      }else{
        if(isOrgChild){
          url = context+"/client/cmp/popuser/mobile/getPopuGroupInfo?token="+token+"&groupId="+id+"&type=user"+"&searchData="+search+"&corpId="+realCorpId+searchLimit;
        }else{
          url = context+"/client/cmp/popuser/mobile/getPopuGroupInfo?token="+token+"&groupId="+id+"&type=group"+"&searchData="+search+"&corpId="+realCorpId+searchLimit;
        }
      }
    }else if(type == "role"){
      url = context+"/client/cmp/popuser/mobile/getPopuRoleInfo?token="+token+"&roleName="+search+"&corpId="+realCorpId;
    }
    return url;
  }

  //点击面包屑导航
  handleNavClick(id, type, navType){
    let t = this;
    var checkType = this.props.checkType;
    var chooseType = this.getChooseType();
    if(type == "user"){
      var navList = t.state.navUserList;
      var index = navList.length - 1;
      var selectUserNum = 0;
      var isShowNav = true, isShowCheckAll = true;
      if(checkType=="radio" || id=="0"){
        isShowCheckAll = false;
      }
      var url = "";
      if(id == "0"){
        isShowNav = false;
        navList = [];
        id = "";
        url = t.getFetchUrl("org", "", "", false, false);
      }else{
        for(var i=0; i<navList.length; i++){
          if(navList[i].id == id){
            navList.splice(i+1, navList.length-i);
            break;
          }
        }
        url = t.getFetchUrl("user", id, "", true, true);
      }
      fetch(url,{
        method: "GET",
        mode: "cors",
        headers: {
          'Accept': 'application/json, text/plain, */*',
          'Content-Type': 'application/x-www-form-urlencoded'
        }
      }).then((response) => response.json()).then((result) => {//alert(JSON.stringify(result));
        //console.log("fetch请求数据"+JSON.stringify(result));
        var orgList = [], userList = [];
        if(id == ""){
          orgList = result.data;
        }else{
          orgList = result.data.orgList;
          userList = result.data.userList;
        }
        if(orgList==null || orgList==undefined){
          orgList = [];
        }
        if(userList==null || userList==undefined || userList.length<=0){
          userList = [];
        }else{
          var selectUsers = t.state.selectedList.selectUsers;
          selectUserNum = t.dataIsChecked(userList, selectUsers, selectUserNum);
          if(selectUserNum == userList.length){
            navList[navList.length-1].checkAll = true;
          }
        }
        t.setState({
          userOrgList: orgList,
          userList: userList,
          selectUserNum: selectUserNum,
          navUserList: navList,
          isShowNav: isShowNav,
          isShowCheckAll: isShowCheckAll
        },()=>{t.instance.update(t.getContent())});
      }).catch((error) => {
        alert("错误："+error);
      });
    }else if(type == "org"){
      var navList = t.state.navOrgList;
      var index = navList.length - 1;
      var selectOrgNum = 0, noUseOrgNum = 0;
      var isShowNav = true, isShowCheckAll = true;
      if(checkType == 'radio'){
        isShowCheckAll = false;
      }
      var url = "";
      if(id == "0"){
        isShowNav = false;
        navList = [{"id": "0", "orgName": "全部", "checkAll": false}];
        id = "";
        url = t.getFetchUrl("org", id, this.state.orgName, false, true);
      }else{
        for(var i=0; i<navList.length; i++){
          if(navList[i].id == id){
            navList.splice(i+1, navList.length-i);
            break;
          }
        }
        url = t.getFetchUrl("org", id, this.state.orgName, true, true);
      }
      fetch(url,{
        method: "GET",
        mode: "cors",
        headers: {
          'Accept': 'application/json, text/plain, */*',
          'Content-Type': 'application/x-www-form-urlencoded'
        }
      }).then((response) => response.json()).then((result) => {//alert(JSON.stringify(result));
        //console.log("fetch请求数据"+JSON.stringify(result));
        var orgList = result.data.orgList;
        var userList = result.data.userList;
        if(orgList==undefined && userList==undefined){
          orgList = result.data;
        }
        var checkAllOrg = true;
        if(orgList==null || orgList==undefined){
          orgList = [];
        }else{
          if(chooseType.indexOf("userNotOrg") < 0) {
            var selectOrgs = t.state.selectedList.selectOrgs;
            selectOrgNum = t.dataIsChecked(orgList, selectOrgs, selectOrgNum);
            noUseOrgNum = t.countNoUseNum(orgList);
            if (selectOrgNum != (orgList.length - noUseOrgNum)) {
              checkAllOrg = false;
            }
          }
        }
        var selectUserNum = 0;
        var checkAllUser = true;
        if(userList==null || userList==undefined){
          userList = [];
        }else{
          if(chooseType.indexOf("userNotOrg")>=0 || chooseType.indexOf("userAndOrg")>=0) {
            var selectUsers = t.state.selectedList.selectUsers;
            selectUserNum = t.dataIsChecked(userList, selectUsers, selectUserNum);
            if (selectUserNum != userList.length) {
              checkAllUser = false;
            }
          }
        }
        if (orgList.length==noUseOrgNum && userList.length==0) {//全部不可选
          navList[navList.length - 1].canUse = "0";
        } else {
          navList[navList.length - 1].canUse = "1";
        }
        if(checkAllUser && checkAllOrg){
          navList[navList.length-1].checkAll = true;
        }
        t.setState({
          orgList: orgList,
          orgUserList: userList,
          selectOrgNum: selectOrgNum,
          noUseOrgNum: noUseOrgNum,
          selectOrgUserNum: selectUserNum,
          navOrgList: navList,
          isShowNav: isShowNav,
          isShowCheckAll: isShowCheckAll
        },()=>{t.instance.update(t.getContent())});
      }).catch((error) => {
        alert("错误："+error);
      });
    }else if(type == "station"){
      var navList = t.state.navStationList;
      var index = navList.length - 1;
      var selectStaNum = 0, noUseStationNum = 0;
      var isShowNav = true, isShowCheckAll = true;
      if(checkType=="radio" || (id=="0" && t.state.staSelectType=="1")){
        isShowCheckAll = false;
      }
      var url = "";
      if(id == "0"){
        id = "";
        isShowNav = false;
        navList = [{"id": "0", "orgName": "全部", "checkAll": false}];
        url = t.getFetchUrl("org", "", "", false, false);
      }else{
        for(var i=0; i<navList.length; i++){
          if(navList[i].id == id){
            navList.splice(i+1, navList.length-i);
            break;
          }
        }
        url = t.getFetchUrl("station", id, "", true, true);
      }
      var staSelectType = this.state.staSelectType, stationName = this.state.stationName;
      if(staSelectType=="0" || navType=="station"){
        url = t.getFetchUrl("station", id, stationName, false, true);
      }
      fetch(url,{
        method: "GET",
        mode: "cors",
        headers: {
          'Accept': 'application/json, text/plain, */*',
          'Content-Type': 'application/x-www-form-urlencoded'
        }
      }).then((response) => response.json()).then((result) => {//alert(JSON.stringify(result));
        //console.log("fetch请求数据"+JSON.stringify(result));
        var orgList = [], stationList = [];
        if(navType=="station" || staSelectType=="0"){
          orgList = [];
          stationList = result.data;
        }else{
          if(id == ""){
            orgList = result.data;
          }else{
            orgList = result.data.orgList;
            stationList = result.data.stationList;
          }
        }
        if(orgList==null || orgList==undefined){
          orgList = [];
        }
        if(stationList==null || stationList==undefined || stationList.length<=0){
          stationList = [];
        }else{
          var selectStations = t.state.selectedList.selectStations;
          selectStaNum = t.dataIsChecked(stationList, selectStations, selectStaNum);
          noUseStationNum = t.countNoUseNum(stationList);
          if(stationList.length == noUseStationNum){//全部不可选
            navList[navList.length-1].canUse = "0";
          }else{
            navList[navList.length-1].canUse = "1";
            if(selectStaNum == (stationList.length-noUseStationNum)){
              navList[navList.length-1].checkAll = true;
            }
          }
        }
        t.setState({
          stationOrgList: orgList,
          stationList: stationList,
          selectStaNum: selectStaNum,
          noUseStationNum: noUseStationNum,
          navStationList: navList,
          isShowNav: isShowNav,
          isShowCheckAll: isShowCheckAll
        },()=>{t.instance.update(t.getContent())});
      }).catch((error) => {
        alert("错误："+error);
      });
    }else if(type == "group"){
      var navList = t.state.navGroupList;
      var index = navList.length - 1;
      var selectGroupNum = 0, noUseGroupNum = 0, selectGroupUserNum = 0;
      var isShowNav = true, isShowCheckAll = true;
      if(checkType == 'radio'){
        isShowCheckAll = false;
      }
      var groupName = this.state.groupName;
      var url = "";
      if(id == "0"){
        id = "";
        isShowNav = false;
        navList = [{"id": "0", "groupName": "全部", "checkAll": false}];
        url = t.getFetchUrl("group", id, groupName, false, true);
      }else{
        for(var i=0; i<navList.length; i++){
          if(navList[i].id == id){
            navList.splice(i+1, navList.length-i);
            break;
          }
        }
        url = t.getFetchUrl("group", id, groupName, true, true);
      }
      fetch(url,{
        method: "GET",
        mode: "cors",
        headers: {
          'Accept': 'application/json, text/plain, */*',
          'Content-Type': 'application/x-www-form-urlencoded'
        }
      }).then((response) => response.json()).then((result) => {//alert(JSON.stringify(result));
        //console.log("fetch请求数据"+JSON.stringify(result));
        var groupList = result.data.groupList;
        var checkAllGroup = true;
        if(groupList==null || groupList==undefined){
          groupList = [];
        }else{
          if(chooseType.indexOf("userNotGroup") < 0) {
            var selectGroups = t.state.selectedList.selectGroups;
            selectGroupNum = t.dataIsChecked(groupList, selectGroups, selectGroupNum);
            noUseGroupNum = t.countNoUseNum(groupList);
            if (selectGroupNum != (groupList.length - noUseGroupNum)) {
              checkAllGroup = false;
            }
          }
        }
        var userList = result.data.userList;
        var selectUserNum = 0;
        var checkAllUser = true;
        if(userList==null || userList==undefined){
          userList = [];
        }else{
          if(chooseType.indexOf("userNotGroup")>=0 || chooseType.indexOf("userAndGroup")>=0) {
            var selectUsers = t.state.selectedList.selectUsers;
            selectUserNum = t.dataIsChecked(userList, selectUsers, selectUserNum);
            if (selectUserNum != userList.length) {
              checkAllUser = false;
            }
          }
        }
        if (groupList.length==noUseGroupNum && userList.length==0) {//全部不可选
          navList[navList.length - 1].canUse = "0";
        } else {
          navList[navList.length - 1].canUse = "1";
        }
        if(checkAllGroup && checkAllUser){
          navList[navList.length-1].checkAll = true;
        }
        t.setState({
          groupList: groupList,
          groupUserList: userList,
          selectGroupNum: selectGroupNum,
          noUseGroupNum: noUseGroupNum,
          selectGroupUserNum: selectUserNum,
          navGroupList: navList,
          isShowNav: isShowNav,
          isShowCheckAll: isShowCheckAll
        },()=>{t.instance.update(t.getContent())});
      }).catch((error) => {
        alert("错误："+error);
      });
    }
  }

  //修改获取的数据选中状态
  dataIsChecked(data, selectData, selectNum){
    var checkType = this.props.checkType;
    for(var j=0; j<data.length; j++){
      data[j].checked = false;
      for(var i = 0; i<selectData.length; i++) {
        if(selectData[i].id == data[j].id){
          data[j].checked = true;
          if(checkType == "radio"){
            return 1;
          }else{
            selectNum ++;
            break;
          }
        }
      }
    }
    return selectNum;
  }

  //用户tab页进入下一级组织
  handleUserShow(orgId){
    var orgList = this.state.userOrgList;
    var navList = this.state.navUserList;
    var selectUserNum = 0;
    var index = navList.length-1;
    var currentOrg = {};
    for(var i=0; i<orgList.length; i++){
      if(orgList[i].id == orgId){
        currentOrg = orgList[i];
      }
      if(navList.length > 0){
        if(navList[index].id == orgList[i].id){
          navList.splice(index, 1);
          break;
        }
      }else{
        break;
      }
    }
    navList.push(currentOrg);
    var isShowCheckAll = true;
    if(this.props.checkType == "radio"){
      isShowCheckAll = false;
    }
    //获取下级组织用户数据
    let t = this;
    var url = t.getFetchUrl("user", orgId, "", true, true);
    fetch(url,{
      method: "GET",
      mode: "cors",
      headers: {
        'Accept': 'application/json, text/plain, */*',
        'Content-Type': 'application/x-www-form-urlencoded'
      }
    }).then(response => response.json()).then(result => {//alert(JSON.stringify(result));
      //console.log("fetch请求数据"+JSON.stringify(result));
      var data = result.data;
      if(data!=null && data!=undefined){
        var orgList = data.orgList;
        if(orgList==null || orgList==undefined){
          orgList = [];
        }
        var userList = data.userList;
        if(userList==null || userList==undefined){
          userList = [];
        }else{
          var selectUsers = t.state.selectedList.selectUsers;
          selectUserNum = t.dataIsChecked(userList, selectUsers, selectUserNum);
          if(selectUserNum == userList.length){
            navList[navList.length-1].checkAll = true;
          }
        }
        t.setState({
          userOrgList: orgList,
          userList: userList,
          selectUserNum: selectUserNum,
          navUserList: navList,
          isShowNav: true,
          isShowCheckAll: isShowCheckAll
        },()=>{t.instance.update(t.getContent())});
      }
    }).catch((error) => {
      alert("错误:" + error)
      //console.log("错误："+error);
    });
  }

  //组织tab页进入下一级组织
  handleOrgShow(orgId){
    var chooseType = this.getChooseType();
    var orgList = this.state.orgList;
    var orgUserList = this.state.orgUserList;
    var navList = this.state.navOrgList;
    var selectOrgNum = 0, noUseOrgNum = 0, selectOrgUserNum = 0;
    var index = navList.length-1;
    var currentOrg = {};
    for(var i=0; i<orgList.length; i++){
      if(orgList[i].id == orgId){
        currentOrg = orgList[i];
      }
      if(navList.length > 0){
        if(navList[index].id == orgList[i].id){
          navList.splice(index, 1);
          break;
        }
      }else{
        break;
      }
    }
    navList.push(currentOrg);
    var isShowCheckAll = true;
    if(this.props.checkType == "radio"){
      isShowCheckAll = false;
    }
    //获取下级组织数据
    let t = this;
    var url = t.getFetchUrl("org", orgId, this.state.orgName, true, true);
    fetch(url,{
      method: "GET",
      mode: "cors",
      headers: {
        'Accept': 'application/json, text/plain, */*',
        'Content-Type': 'application/x-www-form-urlencoded'
      }
    }).then((response) => response.json()).then((result) => {//alert(JSON.stringify(result));
      //console.log("fetch请求数据"+JSON.stringify(result));
      var orgList = result.data.orgList;
      var userList = result.data.userList;
      if(orgList==undefined && userList==undefined){
        orgList = result.data;
      }
      var checkAllOrg = true;
      if(orgList==null || orgList==undefined){
        orgList = [];
      }else{
        if(chooseType.indexOf("userNotOrg") < 0) {
          var selectOrgs = t.state.selectedList.selectOrgs;
          selectOrgNum = t.dataIsChecked(orgList, selectOrgs, selectOrgNum);
          noUseOrgNum = t.countNoUseNum(orgList);
          if (selectOrgNum != (orgList.length - noUseOrgNum)) {
            checkAllOrg = false;
          }
        }
      }
      var selectUserNum = 0;
      var checkAllUser = true;
      if(userList==null || userList==undefined){
        userList = [];
      }else{
        if(chooseType.indexOf("userNotOrg")>=0 || chooseType.indexOf("userAndOrg")>=0) {
          var selectUsers = t.state.selectedList.selectUsers;
          selectUserNum = t.dataIsChecked(userList, selectUsers, selectUserNum);
          if (selectUserNum != userList.length) {
            checkAllUser = false;
          }
        }
      }
      if (orgList.length==noUseOrgNum && userList.length==0) {//全部不可选
        navList[navList.length - 1].canUse = "0";
      } else {
        navList[navList.length - 1].canUse = "1";
      }
      if(checkAllUser && checkAllOrg){
        navList[navList.length-1].checkAll = true;
      }
      t.setState({
        orgList: orgList,
        orgUserList: userList,
        selectOrgNum: selectOrgNum,
        noUseOrgNum: noUseOrgNum,
        selectOrgUserNum: selectUserNum,
        navOrgList: navList,
        isShowNav: true,
        isShowCheckAll: isShowCheckAll
      },()=>{t.instance.update(t.getContent())});
    }).catch((error) => {
      alert("错误："+error);
    });
  }

  //岗位tab页进入下一级组织
  handleStationShow(id, navType){
    var orgList = this.state.stationOrgList;
    var stationList = this.state.stationList;
    var navList = this.state.navStationList;
    var selectStaNum = 0, noUseStationNum = 0;
    var index = navList.length-1;
    var current = {};
    if(navType == "station"){
      for(var i=0; i<stationList.length; i++){
        if(stationList[i].id == id){
          current = stationList[i];
          current.type = "station";
        }
        if(navList.length > 0){
          if(navList[index].id == stationList[i].id){
            navList.splice(index, 1);
            break;
          }
        }else{
          break;
        }
      }
    }else{
      for(var i=0; i<orgList.length; i++){
        if(orgList[i].id == id){
          current = orgList[i];
          current.type = "org";
        }
        if(navList.length > 0){
          if(navList[index].id == orgList[i].id){
            navList.splice(index, 1);
            break;
          }
        }else{
          break;
        }
      }
    }
    navList.push(current);
    var isShowCheckAll = true;
    if(this.props.checkType == "radio"){
      isShowCheckAll = false;
    }
    //获取下级组织用户数据
    let t = this;
    var staSelectType = this.state.staSelectType;
    var url = "";
    if(staSelectType=="0" || navType=="station"){
      url = t.getFetchUrl("station", id, this.state.stationName, false, true);
    }else{
      url = t.getFetchUrl("station", id, "", true, true);
    }
    fetch(url,{
      method: "GET",
      mode: "cors",
      headers: {
        'Accept': 'application/json, text/plain, */*',
        'Content-Type': 'application/x-www-form-urlencoded'
      }
    }).then((response) => response.json()).then((result) => {//alert(JSON.stringify(result));
      //console.log("fetch请求数据"+JSON.stringify(result));
      var orgList = [], stationList = [];
      if(navType=="station" || staSelectType=="0"){
        orgList = [];
        stationList = result.data;
      }else{
        orgList = result.data.orgList;
        stationList = result.data.stationList;
      }
      if(orgList==null || orgList==undefined){
        orgList = [];
      }
      if(stationList==null || stationList==undefined){
        stationList = [];
      }else{
        var selectStations = t.state.selectedList.selectStations;
        selectStaNum = t.dataIsChecked(stationList, selectStations, selectStaNum);
        noUseStationNum = t.countNoUseNum(stationList);
        if(stationList.length == noUseStationNum){//全部不可选
          navList[navList.length-1].canUse = "0";
        }else{
          navList[navList.length-1].canUse = "1";
          if(selectStaNum == (stationList.length-noUseStationNum)){
            navList[navList.length-1].checkAll = true;
          }
        }
      }
      t.setState({
        stationOrgList: orgList,
        stationList: stationList,
        selectStaNum: selectStaNum,
        noUseStationNum: noUseStationNum,
        navStationList: navList,
        isShowNav: true,
        isShowCheckAll: isShowCheckAll
      },()=>{t.instance.update(t.getContent())});
    }).catch((error) => {
      alert("错误："+error);
    });
  }

  //群组tab页进入下一级群组
  handleGroupShow(groupId){
    var chooseType = this.getChooseType();
    var groupList = this.state.groupList;
    var groupUserList = this.state.groupUserList;
    var navList = this.state.navGroupList;
    var selectGroupNum = 0, noUseGroupNum = 0;
    var index = navList.length-1;
    var currentGroup = {};
    for(var i=0; i<groupList.length; i++){
      if(groupList[i].id == groupId){
        currentGroup = groupList[i];
      }
      if(navList.length > 0){
        if(navList[index].id == groupList[i].id){
          navList.splice(index, 1);
          break;
        }
      }else{
        break;
      }
    }
    navList.push(currentGroup);
    var isShowCheckAll = true;
    if(this.props.checkType == "radio"){
      isShowCheckAll = false;
    }
    //获取下级组织数据
    let t = this;
    var url = t.getFetchUrl("group", groupId, this.state.groupName, true, true);
    fetch(url,{
      method: "GET",
      mode: "cors",
      headers: {
        'Accept': 'application/json, text/plain, */*',
        'Content-Type': 'application/x-www-form-urlencoded'
      }
    }).then((response) => response.json()).then((result) => {//alert(JSON.stringify(result));
      //console.log("fetch请求数据"+JSON.stringify(result));
      var groupList = result.data.groupList;
      var checkAllGroup = true;
      if(groupList==null || groupList==undefined){
        groupList = [];
      }else{
        if(chooseType.indexOf("userNotGroup") < 0) {
          var selectGroups = t.state.selectedList.selectGroups;
          selectGroupNum = t.dataIsChecked(groupList, selectGroups, selectGroupNum);
          noUseGroupNum = t.countNoUseNum(groupList);
          if (selectGroupNum != (groupList.length - noUseGroupNum)) {
            checkAllGroup = false;
          }
        }
      }
      var userList = result.data.userList;
      var selectUserNum = 0;
      var checkAllUser = true;
      if(userList==null || userList==undefined){
        userList = [];
      }else{
        if(chooseType.indexOf("userNotGroup")>=0 || chooseType.indexOf("userAndGroup")>=0) {
          var selectUsers = t.state.selectedList.selectUsers;
          selectUserNum = t.dataIsChecked(userList, selectUsers, selectUserNum);
          if (selectUserNum != userList.length) {
            checkAllUser = false;
          }
        }
      }
      if (groupList.length==noUseGroupNum && userList.length==0) {//全部不可选
        navList[navList.length - 1].canUse = "0";
      } else {
        navList[navList.length - 1].canUse = "1";
      }
      if(checkAllGroup && checkAllUser){
        navList[navList.length-1].checkAll = true;
      }
      t.setState({
        groupList: groupList,
        groupUserList: userList,
        selectGroupNum: selectGroupNum,
        noUseGroupNum: noUseGroupNum,
        selectGroupUserNum: selectUserNum,
        navGroupList: navList,
        isShowNav: true,
        isShowCheckAll: isShowCheckAll
      },()=>{t.instance.update(t.getContent())});
    }).catch((error) => {
      alert("错误："+error);
    });
  }

  //单个选中方法
  checkOneItem(canUse, checked, selectData, dataList, checkType, total, selectNum, index, scopeList, type){
    var result = {"total": total, selectNum: selectNum};
    if(canUse == "1"){
      if(checked){
        if(checkType == "radio"){
          if(selectData.length == 0){
            total ++;
          }
          selectNum = 1;
          selectData[0] = dataList[index];
          for(var i=0; i<dataList.length; i++){
            if(dataList[i].checked && i!=index){
              dataList[i].checked = false;
              break;
            }
          }
        }else{
          total ++;
          selectNum ++;
          selectData.push(dataList[index]);
        }
        var scope = { "scopeValue": dataList[index].id };
        if(type == "user"){
          scope.scopeType = "user";
          scope.scopeName = dataList[index].userName;
        }else if(type == "org"){
          scope.scopeType = "org";
          scope.scopeName = dataList[index].orgName;
		  scope.orgType = dataList[index].orgType;
        }else if(type == "role"){
          scope.scopeType = "role";
          scope.scopeName = dataList[index].roleName;
        }else if(type == "station"){
          scope.scopeType = "station";
          scope.scopeName = dataList[index].stationName;
        }else if(type == "group"){
          scope.scopeType = "group";
          scope.scopeName = dataList[index].groupName;
        }
        if(checkType == "radio"){
          scopeList[0] = scope;
        }else{
          scopeList.push(scope);
        }
      }else{
        total --;
        selectNum --;
        if(checkType == "radio"){
          selectData.splice(0, 1);
          scopeList.splice(0, 1);
        }else{
          for(var i=0; i<selectData.length; i++){
            if(selectData[i].id == dataList[index].id){
              selectData.splice(i, 1);
              break;
            }
          }
        }
        for(var j=0; j<scopeList.length; j++){
          if(scopeList[j].scopeValue == dataList[index].id){
            scopeList.splice(j, 1);
            break;
          }
        }
      }
    }
    result.selectNum = selectNum;
    result.total = total;
    return result;
  }
  //单个选中方法
  checkOneCommonItem(checked, selectData, dataList, selectedData, checkType, total, selectNum, index, scopeList){
    var result = {"total": total, selectNum: selectNum};
    if(checked){
      if(checkType == "radio"){
        if(selectData.length == 0){
          total ++;
        }
        selectNum = 1;
        selectData[0] = selectedData;
        for(var i=0; i<dataList.length; i++){
          if(dataList[i].checked && i!=index){
            dataList[i].checked = false;
            break;
          }
        }
        scopeList[0] = dataList[index];
      }else{
        total ++;
        selectNum ++;
        selectData.push(selectedData);
        scopeList.push(dataList[index]);
      }
    }else{
      total --;
      selectNum --;
      if(checkType == "radio"){
        selectData.splice(0, 1);
        scopeList.splice(0, 1);
      }else{
        for(var i=0; i<selectData.length; i++){
          if(selectData[i].id == selectedData.id){
            selectData.splice(i, 1);
            break;
          }
        }
      }
      for(var j=0; j<scopeList.length; j++){
        if(scopeList[j].scopeValue == selectedData.id){
          scopeList.splice(j, 1);
          break;
        }
      }
    }
    result.selectNum = selectNum;
    result.total = total;
    return result;
  }

  //单个选中
  checkItemMember(index,type){
    let t = this;
    var checkType = this.props.checkType;
    var chooseType = this.getChooseType();
    var scopeList = this.state.scopeList;
    if("common" == type){
      var commonUsedData = t.state.commonUsedData;
      var common = commonUsedData[index];
      var total = t.state.total;
      var selectCommonNum = t.state.selectCommonNum;
      var selectedList = t.state.selectedList;
      if(common.checked == true){
        commonUsedData[index].checked = false
      }else{
        commonUsedData[index].checked = true;
      }
      var selectedData = {id: common.scopeValue};
      var selectData = [];
      if(common.scopeType == "user"){
        selectedData.userName = common.scopeName;
        selectedData.imageId = common.imageId;
        selectData = selectedList.selectUsers;
      }else if(common.scopeType == "org"){
        selectedData.orgName = common.scopeName;
        selectData = selectedList.selectOrgs;
      }else if(common.scopeType == "role"){
        selectedData.roleName = common.scopeName;
        selectData = selectedList.selectRoles;
      }else if(common.scopeType == "station"){
        selectedData.stationName = common.scopeName;
        selectData = selectedList.selectStations;
      }else if(common.scopeType == "group"){
        selectedData.groupName = common.scopeName;
        selectData = selectedList.selectGroups;
      }
      if(selectData==null || selectData==undefined || selectData.length==0){
        selectData = [];
      }
      var result = t.checkOneCommonItem(commonUsedData[index].checked, selectData, commonUsedData, selectedData, checkType, total, selectCommonNum, index, scopeList);
      total = result.total;
      selectUserNum = result.selectNum;
      if(common.scopeType == "user"){
         selectedList.selectUsers = selectData;
      }else if(common.scopeType == "org"){
        selectedList.selectOrgs = selectData;
      }else if(common.scopeType == "role"){
        selectedList.selectRoles = selectData;
      }else if(common.scopeType == "station"){
        selectedList.selectStations = selectData;
      }else if(common.scopeType == "group"){
        selectedList.selectGroups = selectData;
      }
      t.setState({
        commonUsedData: commonUsedData,
        total: total,
        selectCommonNum: selectUserNum,
        selectedList: selectedList,
        scopeList: scopeList
      },()=>{this.instance.update(this.getContent())});
    }else if("user" == type){
      var userList = t.state.userList;
      userList[index].checked = !userList[index].checked;
      var total = t.state.total;
      var selectUserNum = t.state.selectUserNum;//当前组织下选中的用户数量
      var selectedList = t.state.selectedList;
      var selectUsers = selectedList.selectUsers;
      if(selectUsers==null || selectUsers==undefined){
        selectUsers = [];
      }
      var result = t.checkOneItem("1",userList[index].checked, selectUsers, userList, checkType, total, selectUserNum, index, scopeList, "user");
      total = result.total;
      selectUserNum = result.selectNum;
      selectedList.selectUsers = selectUsers;
      var navList = t.state.navUserList;
      if(selectUserNum == userList.length){
        navList[navList.length-1].checkAll = true;
      }else{
        navList[navList.length-1].checkAll = false;
      }
      t.setState({
        userList: userList,
        total: total,
        selectUserNum: selectUserNum,
        navUserList: navList,
        selectedList: selectedList,
        scopeList: scopeList
      },()=>{this.instance.update(this.getContent())});
    }else if("org" == type){
      var orgList = t.state.orgList;
      orgList[index].checked = !orgList[index].checked;
      var total = t.state.total;
      var selectOrgNum = t.state.selectOrgNum;//当前组织下选中的用户数量
      var selectedList = t.state.selectedList;
      var selectOrgs = selectedList.selectOrgs;
      if(selectOrgs==null || selectOrgs==undefined){
        selectOrgs = [];
      }
      var result = t.checkOneItem(orgList[index].canUse,orgList[index].checked, selectOrgs, orgList, checkType, total, selectOrgNum, index, scopeList, "org");
      total = result.total;
      selectOrgNum = result.selectNum;
      selectedList.selectOrgs = selectOrgs;
      var navList = t.state.navOrgList;
      var noUseOrgNum = t.state.noUseOrgNum;
      var selectOrgUserNum = 0;
      var orgUserList = [];
      if(chooseType.indexOf("userAndOrg") >= 0) {
        selectOrgUserNum = t.state.selectOrgUserNum;
        orgUserList = t.state.orgUserList;
      }
      if((selectOrgNum+selectOrgUserNum) == (orgUserList.length+orgList.length-noUseOrgNum)){
        navList[navList.length-1].checkAll = true;
      }else{
        navList[navList.length-1].checkAll = false;
      }

      t.setState({
        orgList: orgList,
        total: total,
        selectOrgNum: selectOrgNum,
        navOrgList: navList,
        selectedList: selectedList,
        scopeList: scopeList
      },()=>{this.instance.update(this.getContent());});
    }else if("orgUser" == type){
      var orgUserList = t.state.orgUserList;
      orgUserList[index].checked = !orgUserList[index].checked;
      var total = t.state.total;
      var selectOrgUserNum = t.state.selectOrgUserNum;//当前组织下选中的用户数量
      var selectedList = t.state.selectedList;
      var selectUsers = selectedList.selectUsers;
      if(selectUsers==null || selectUsers==undefined){
        selectUsers = [];
      }
      var result = t.checkOneItem("1",orgUserList[index].checked, selectUsers, orgUserList, checkType, total, selectOrgUserNum, index, scopeList, "user");
      total = result.total;
      selectOrgUserNum = result.selectNum;
      selectedList.selectUsers = selectUsers;
      var navList = t.state.navOrgList;
      var selectOrgNum = 0, noUseOrgNum = 0;
      var orgList = [];
      if(chooseType.indexOf("userAndOrg") >= 0) {
        noUseOrgNum = t.state.noUseOrgNum;
        selectOrgNum = t.state.selectOrgNum;
        orgList = t.state.orgList;
      }
      if((selectOrgNum+selectOrgUserNum) == (orgList.length+orgUserList.length-noUseOrgNum)){
        navList[navList.length-1].checkAll = true;
      }else{
        navList[navList.length-1].checkAll = false;
      }

      t.setState({
        orgUserList: orgUserList,
        total: total,
        selectOrgUserNum: selectOrgUserNum,
        navOrgList: navList,
        selectedList: selectedList,
        scopeList: scopeList
      },()=>{this.instance.update(this.getContent());});
    }else if("role" == type){
      var roleList = t.state.roleList;
      roleList[index].checked = !roleList[index].checked;
      var total = t.state.total;
      var selectRoleNum = t.state.selectRoleNum;//当前组织下选中的用户数量
      var selectedList = t.state.selectedList;
      var selectRoles = selectedList.selectRoles;
      if(selectRoles==null || selectRoles==undefined){
        selectRoles = [];
      }
      var result = t.checkOneItem("1",roleList[index].checked, selectRoles, roleList, checkType, total, selectRoleNum, index, scopeList, "role");
      total = result.total;
      selectRoleNum = result.selectNum;
      selectedList.selectRoles = selectRoles;
      var roleCheckAll = t.state.roleCheckAll;
      if(roleList.length == selectRoleNum){
        roleCheckAll = true;
      }else{
        roleCheckAll = false;
      }
      t.setState({
        roleList: roleList,
        total: total,
        selectRoleNum: selectRoleNum,
        selectedList: selectedList,
        roleCheckAll: roleCheckAll,
        scopeList: scopeList
      },()=>{this.instance.update(this.getContent())});
    }else if("station" == type){
      var stationList = t.state.stationList;
      stationList[index].checked = !stationList[index].checked;
      var total = t.state.total;
      var selectStaNum = t.state.selectStaNum;//当前组织下选中的用户数量
      var selectedList = t.state.selectedList;
      var selectStations = selectedList.selectStations;
      if(selectStations==null || selectStations==undefined){
        selectStations = [];
      }
      var result = t.checkOneItem(stationList[index].canUse,stationList[index].checked, selectStations, stationList, checkType, total, selectStaNum, index, scopeList, "station");
      total = result.total;
      selectStaNum = result.selectNum;
      selectedList.selectStations = selectStations;
      var navList = t.state.navStationList;
      var noUseStationNum = t.state.noUseStationNum;
      if(selectStaNum == (stationList.length-noUseStationNum)){
        navList[navList.length-1].checkAll = true;
      }else{
        navList[navList.length-1].checkAll = false;
      }
      t.setState({
        stationList: stationList,
        total: total,
        selectStaNum: selectStaNum,
        selectedList: selectedList,
        navStationList: navList,
        scopeList: scopeList
      },()=>{this.instance.update(this.getContent())});
    }else if("group" == type){
      var groupList = t.state.groupList;
      groupList[index].checked = !groupList[index].checked;
      var total = t.state.total;
      var selectGroupNum = t.state.selectGroupNum;//当前组织下选中的用户数量
      var selectedList = t.state.selectedList;
      var selectGroups = selectedList.selectGroups;
      if(selectGroups==null || selectGroups==undefined){
        selectGroups = [];
      }
      var result = t.checkOneItem(groupList[index].canUse,groupList[index].checked, selectGroups, groupList, checkType, total, selectGroupNum, index, scopeList, "group");
      total = result.total;
      selectGroupNum = result.selectNum;
      selectedList.selectGroups = selectGroups;
      var navList = t.state.navGroupList;
      var noUseGroupNum = t.state.noUseGroupNum;
      var selectGroupUserNum = 0;
      var groupUserList = [];
      if(chooseType.indexOf("userAndGroup") >= 0) {
        selectGroupUserNum = t.state.selectGroupUserNum;
        groupUserList = t.state.groupUserList;
      }
      if((selectGroupNum+selectGroupUserNum) == (groupUserList.length+groupList.length-noUseGroupNum)){
        navList[navList.length-1].checkAll = true;
      }else{
        navList[navList.length-1].checkAll = false;
      }
      t.setState({
        groupList: groupList,
        total: total,
        selectGroupNum: selectGroupNum,
        selectedList: selectedList,
        navGroupList: navList,
        scopeList: scopeList
      },()=>{this.instance.update(this.getContent())});
    }else if("groupUser" == type){
      var groupUserList = t.state.groupUserList;
      groupUserList[index].checked = !groupUserList[index].checked;
      var total = t.state.total;
      var selectGroupUserNum = t.state.selectGroupUserNum;//当前组织下选中的用户数量
      var selectedList = t.state.selectedList;
      var selectUsers = selectedList.selectUsers;
      if(selectUsers==null || selectUsers==undefined){
        selectUsers = [];
      }
      var result = t.checkOneItem("1",groupUserList[index].checked, selectUsers, groupUserList, checkType, total, selectGroupUserNum, index, scopeList, "user");
      total = result.total;
      selectGroupUserNum = result.selectNum;
      selectedList.selectUsers = selectUsers;
      var navList = t.state.navGroupList;
      var selectGroupNum = 0, noUseGroupNum = 0;
      var groupList = [];
      if(chooseType.indexOf("userAndGroup") >= 0) {
        noUseGroupNum = t.state.noUseGroupNum;
        selectGroupNum = t.state.selectGroupNum;
        groupList = t.state.groupList;
      }
      if((selectGroupNum+selectGroupUserNum) == (groupList.length+groupUserList.length-noUseGroupNum)){
        navList[navList.length-1].checkAll = true;
      }else{
        navList[navList.length-1].checkAll = false;
      }

      t.setState({
        groupUserList: groupUserList,
        total: total,
        selectGroupUserNum: selectGroupUserNum,
        navOrgList: navList,
        selectedList: selectedList,
        scopeList: scopeList
      },()=>{t.instance.update(t.getContent());});
    }
  }

  //查看已选或返回选择页面
  handleSelectClick(type) {
    let t = this;
    t.setState({
      isSelectShow: type
    },()=>{ t.instance.update(t.getContent());});
  }

  //删除已选选项
  deleteItemMember(index, type){
    var selectedList = this.state.selectedList;
    var scopeList = this.state.scopeList;
    if(type == "user"){
      var selectUsers = selectedList.selectUsers;
      var user = selectUsers[index];
      selectUsers.splice(index, 1);
      selectedList.selectUsers = selectUsers;
      var userList = this.state.userList;
      var selectUserNum = this.state.selectUserNum;
      for (var i=0; i<userList.length; i++) {
        if(userList[i].id == user.id){
          userList[i].checked = false;
          selectUserNum --;
          break;
        }
      }
      var orgUserList = this.state.orgUserList;
      var selectOrgUserNum = this.state.selectOrgUserNum;
      for (var i=0; i<orgUserList.length; i++) {
        if(orgUserList[i].id == user.id){
          orgUserList[i].checked = false;
          selectOrgUserNum --;
          break;
        }
      }
      var groupUserList = this.state.groupUserList;
      var selectGroupUserNum = this.state.selectGroupUserNum;
      for (var i=0; i<groupUserList.length; i++) {
        if(groupUserList[i].id == user.id){
          groupUserList[i].checked = false;
          selectGroupUserNum --;
          break;
        }
      }
      var navUserList = this.state.navUserList;
      if(navUserList!=null && navUserList.length>0){
        if(selectUserNum < userList.length){
          navUserList[navUserList.length - 1].checkAll = false;
        }
      }
      var navOrgList = this.state.navOrgList;
      if(navOrgList!=null && navOrgList.length>0){
        var selectOrgNum = this.state.selectOrgNum;
        var noUseOrgNum = this.state.noUseOrgNum;
        var orgList = this.state.orgList;
        if((selectOrgNum+selectOrgUserNum) == (orgUserList.length+orgList.length-noUseOrgNum)){
          navOrgList[navOrgList.length-1].checkAll = true;
        }else{
          navOrgList[navOrgList.length-1].checkAll = false;
        }
      }
      var navGroupList = this.state.navGroupList;
      if(navGroupList!=null && navGroupList.length>0){
        var selectGroupNum = this.state.selectGroupNum;
        var noUseGroupNum = this.state.noUseGroupNum;
        var groupList = this.state.groupList;
        if((selectGroupNum+selectGroupUserNum) == (groupUserList.length+groupList.length-noUseGroupNum)){
          navGroupList[navGroupList.length-1].checkAll = true;
        }else{
          navGroupList[navGroupList.length-1].checkAll = false;
        }
      }

      for(var j=0; j<scopeList.length; j++){
        if(scopeList[j].scopeValue == user.id){
          scopeList.splice(j, 1);
          break;
        }
      }
      //改变常用已选
      var commonUsedData = this.state.commonUsedData;
      var selectCommonNum = this.state.selectCommonNum;
      var commonCheckAll = this.state.commonCheckAll;
      if(commonUsedData!=null && commonUsedData!=undefined && commonUsedData.length>0){
        for(var i=0; i<commonUsedData.length; i++){
          if(commonUsedData[i].scopeValue == user.id){
            commonUsedData[i].checked = false;
            selectCommonNum --;
            if(commonCheckAll){
              commonCheckAll = false;
            }
            break;
          }
        }
      }
      this.setState({
        selectCommonNum: selectCommonNum,
        commonUsedData: commonUsedData,
        selectedList: selectedList,
        userList: userList,
        selectUserNum: selectUserNum,
        orgUserList: orgUserList,
        selectOrgUserNum: selectOrgUserNum,
        groupUserList: groupUserList,
        selectGroupUserNum: selectGroupUserNum,
        commonCheckAll: false,
        total: this.state.total - 1,
        navUserList: navUserList,
        navOrgList: navOrgList,
        navGroupList: navGroupList,
        scopeList: scopeList
      },()=>{this.instance.update(this.getContent())});
    }else if(type == "org"){
      var selectOrgs = selectedList.selectOrgs;
      var org = selectOrgs[index];
      selectOrgs.splice(index, 1);
      selectedList.selectOrgs = selectOrgs;
      var orgList = this.state.orgList;
      var selectOrgNum = this.state.selectOrgNum;
      for (var i=0; i<orgList.length; i++) {
        if(orgList[i].id == org.id){
          orgList[i].checked = false;
          selectOrgNum --;
          break;
        }
      }
      var navList = this.state.navOrgList;
      if(navList!=null && navList.length>0){
        var noUseOrgNum = this.state.noUseOrgNum;
        var selectOrgUserNum = this.state.selectOrgUserNum;
        var orgUserList = this.state.orgUserList;
        if((selectOrgNum+selectOrgUserNum) == (orgUserList.length+orgList.length-noUseOrgNum)){
          navList[navList.length-1].checkAll = true;
        }else{
          navList[navList.length-1].checkAll = false;
        }
      }
      for(var j=0; j<scopeList.length; j++){
        if(scopeList[j].scopeValue == org.id){
          scopeList.splice(j, 1);
          break;
        }
      }
      //改变常用已选
      var commonUsedData = this.state.commonUsedData;
      var selectCommonNum = this.state.selectCommonNum;
      var commonCheckAll = this.state.commonCheckAll;
      if(commonUsedData!=null && commonUsedData!=undefined && commonUsedData.length>0){
        for(var i=0; i<commonUsedData.length; i++){
          if(commonUsedData[i].scopeValue == org.id){
            commonUsedData[i].checked = false;
            selectCommonNum --;
            if(commonCheckAll){
              commonCheckAll = false;
            }
            break;
          }
        }
      }
      this.setState({
        selectCommonNum: selectCommonNum,
        commonUsedData: commonUsedData,
        selectedList: selectedList,
        orgList: orgList,
        selectOrgNum: selectOrgNum,
        total: this.state.total - 1,
        navOrgList: navList,
        scopeList: scopeList
      },()=>{this.instance.update(this.getContent())});
    }else if(type == "role"){
      var selectRoles = selectedList.selectRoles;
      var role = selectRoles[index];
      selectRoles.splice(index, 1);
      selectedList.selectRoles = selectRoles;
      var roleList = this.state.roleList;
      var selectRoleNum = this.state.selectRoleNum;
      for (var i=0; i<roleList.length; i++) {
        if(roleList[i].id == role.id){
          roleList[i].checked = false;
          selectRoleNum --;
          break;
        }
      }
      var roleCheckAll = this.state.roleCheckAll;
      if(selectRoleNum < roleList.length){
        roleCheckAll = false;
      }
      for(var j=0; j<scopeList.length; j++){
        if(scopeList[j].scopeValue == role.id){
          scopeList.splice(j, 1);
          break;
        }
      }
      //改变常用已选
      var commonUsedData = this.state.commonUsedData;
      var selectCommonNum = this.state.selectCommonNum;
      if(commonUsedData!=null && commonUsedData!=undefined && commonUsedData.length>0){
        for(var i=0; i<commonUsedData.length; i++){
          if(commonUsedData[i].scopeValue == role.id){
            commonUsedData[i].checked = false;
            selectCommonNum --;
            break;
          }
        }
      }
      this.setState({
        selectCommonNum: selectCommonNum,
        commonUsedData: commonUsedData,
        selectedList: selectedList,
        roleList: roleList,
        selectRoleNum: selectRoleNum,
        total: this.state.total - 1,
        roleCheckAll: roleCheckAll,
        scopeList: scopeList
      },()=>{this.instance.update(this.getContent())});
    }else if(type == "station"){
      var selectStations = selectedList.selectStations;
      var station = selectStations[index];
      selectStations.splice(index, 1);
      selectedList.selectStations = selectStations;
      var stationList = this.state.stationList;
      var selectStaNum = this.state.selectStaNum;
      for (var i=0; i<stationList.length; i++) {
        if(stationList[i].id == station.id){
          stationList[i].checked = false;
          selectStaNum --;
          break;
        }
      }
      var navList = this.state.navStationList;
      var noUseStationNum = this.state.noUseStationNum;
      if(navList!=null && navList.length>0){
        var index = navList.length - 1;
        if(selectStaNum < (stationList.length-noUseStationNum)){
          navList[index].checkAll = false;
        }
      }
      for(var j=0; j<scopeList.length; j++){
        if(scopeList[j].scopeValue == station.id){
          scopeList.splice(j, 1);
          break;
        }
      }
      //改变常用已选
      var commonUsedData = this.state.commonUsedData;
      var selectCommonNum = this.state.selectCommonNum;
      if(commonUsedData!=null && commonUsedData!=undefined && commonUsedData.length>0){
        for(var i=0; i<commonUsedData.length; i++){
          if(commonUsedData[i].scopeValue == station.id){
            commonUsedData[i].checked = false;
            selectCommonNum --;
            break;
          }
        }
      }
      this.setState({
        selectCommonNum: selectCommonNum,
        commonUsedData: commonUsedData,
        selectedList: selectedList,
        stationList: stationList,
        selectStaNum: selectStaNum,
        total: this.state.total - 1,
        navStationList: navList,
        scopeList: scopeList
      },()=>{this.instance.update(this.getContent())});
    }else if(type == "group"){
      var selectGroups = selectedList.selectGroups;
      var group = selectGroups[index];
      selectGroups.splice(index, 1);
      selectedList.selectGroups = selectGroups;
      var groupList = this.state.groupList;
      var selectGroupNum = this.state.selectGroupNum;
      for (var i=0; i<groupList.length; i++) {
        if(groupList[i].id == group.id){
          groupList[i].checked = false;
          selectGroupNum --;
          break;
        }
      }
      var navList = this.state.navGroupList;
      if(navList!=null && navList.length>0){
        var noUseGroupNum = this.state.noUseGroupNum;
        var selectGroupUserNum = this.state.selectGroupUserNum;
        var groupUserList = this.state.groupUserList;
        if((selectGroupNum+selectGroupUserNum) == (groupUserList.length+groupList.length-noUseGroupNum)){
          navList[navList.length-1].checkAll = true;
        }else{
          navList[navList.length-1].checkAll = false;
        }
      }
      for(var j=0; j<scopeList.length; j++){
        if(scopeList[j].scopeValue == group.id){
          scopeList.splice(j, 1);
          break;
        }
      }
      //改变常用已选
      var commonUsedData = this.state.commonUsedData;
      var selectCommonNum = this.state.selectCommonNum;
      if(commonUsedData!=null && commonUsedData!=undefined && commonUsedData.length>0){
        for(var i=0; i<commonUsedData.length; i++){
          if(commonUsedData[i].scopeValue == group.id){
            commonUsedData[i].checked = false;
            selectCommonNum --;
            break;
          }
        }
      }
      this.setState({
        selectCommonNum: selectCommonNum,
        commonUsedData: commonUsedData,
        selectedList: selectedList,
        groupList: groupList,
        selectGroupNum: selectGroupNum,
        total: this.state.total - 1,
        navGroupList: navList,
        scopeList: scopeList
      },()=>{this.instance.update(this.getContent())});
    }
  }

  //清空已选回调函数
  dialogClearItem(isShowDialog){
    let t = this;
    if(isShowDialog){
      Dialog.confirm({
        title: '提示',
        locale: 'zh_CN',
        content: '确定清空所有已选？',
        onConfirm() {
          t.clearSelectedItem();
        },
        onCancel() {
          return;
        },
      });
    }else{
      t.clearSelectedItem();
    }
  }
  clearSelectedItem(){
    var scopeList = this.state.scopeList;
    if(scopeList!=null && scopeList.length>0){
      this.setState({
        scopeList: [],
        selectedList: {selectUsers:[], selectOrgs:[], selectRoles:[], selectStations:[], selectGroups:[]},
        defaultList: [],
        total: 0
      });
      scopeList = [];
      this.props.onChange(scopeList);
    }
  }

  //清空已选选项
  clearItemMember(){
    var t = this;
    Dialog.confirm({
      title: '提示',
      locale: 'zh_CN',
      content: '确定清空所有已选？',
      onConfirm() {
        var selectedList = t.state.selectedList;
        var total = t.state.total;
        //清除常用已选
        var commonUsedData = t.state.commonUsedData;
        if(commonUsedData!=null && commonUsedData!=undefined){
          for(var i=0; i<commonUsedData.length; i++){
            if(commonUsedData[i].checked){
              commonUsedData[i].checked = false;
            }
          }
        }
        //清空用户
        total = total - selectedList.selectUsers.length;
        selectedList.selectUsers = [];
        var userList = t.state.userList;
        for (var i=0; i<userList.length; i++) {
          if(userList[i].checked){
            userList[i].checked = false;
          }
        }
        var orgUserList = t.state.orgUserList;
        for (var i=0; i<orgUserList.length; i++) {
          if(orgUserList[i].checked){
            orgUserList[i].checked = false;
          }
        }
        var groupUserList = t.state.groupUserList;
        for (var i=0; i<groupUserList.length; i++) {
          if(groupUserList[i].checked){
            groupUserList[i].checked = false;
          }
        }
        var navUserList = t.state.navUserList;
        if(navUserList!=null && navUserList.length>0){
          var index = navUserList.length - 1;
          navUserList[index].checkAll = false;
        }
        //清空组织
        total = total - selectedList.selectOrgs.length;
        selectedList.selectOrgs = [];
        var orgList = t.state.orgList;
        for (var i=0; i<orgList.length; i++) {
          if(orgList[i].checked){
            orgList[i].checked = false;
          }
        }
        var navOrgList = t.state.navOrgList;
        if(navOrgList!=null && navOrgList.length>0){
          var index = navOrgList.length - 1;
          navOrgList[index].checkAll = false;
        }
        //清空角色
        total = total - selectedList.selectRoles.length;
        selectedList.selectRoles = [];
        var roleList = t.state.roleList;
        for (var i=0; i<roleList.length; i++) {
          if(roleList[i].checked){
            roleList[i].checked = false;
          }
        }
        //清空岗位
        total = total - selectedList.selectStations.length;
        selectedList.selectStations = [];
        var stationList = t.state.stationList;
        for (var i=0; i<stationList.length; i++) {
          if(stationList[i].checked){
            stationList[i].checked = false;
          }
        }
        var navStationList = t.state.navStationList;
        if(navStationList!=null && navStationList.length>0){
          var index = navStationList.length - 1;
          navStationList[index].checkAll = false;
        }
        //清空群组
        total = total - selectedList.selectGroups.length;
        selectedList.selectGroups = [];
        var groupList = t.state.groupList;
        for (var i=0; i<groupList.length; i++) {
          if(groupList[i].checked){
            groupList[i].checked = false;
          }
        }
        var navGroupList = t.state.navGroupList;
        if(navGroupList!=null && navGroupList.length>0){
          var index = navGroupList.length - 1;
          navGroupList[index].checkAll = false;
        }
        t.setState({
          selectedList: selectedList,
          commonUsedData: commonUsedData,
          selectCommonNum: 0,
          commonCheckAll: false,
          userList: userList,
          selectUserNum: 0,
          total: total,
          navUserList: navUserList,
          orgList: orgList,
          selectOrgNum: 0,
          orgUserList: orgUserList,
          selectOrgUserNum: 0,
          navOrgList: navOrgList,
          roleList: roleList,
          selectRoleNum: 0,
          roleCheckAll: false,
          stationList: stationList,
          selectStaNum: 0,
          navStationList: navStationList,
          groupList: groupList,
          groupUserList: groupUserList,
          selectGroupNum: 0,
          selectGroupUserNum: 0,
          navGroupList: navGroupList,
          scopeList: []
        },()=>{t.instance.update(t.getContent())});
      },
      onCancel() {
        return;
      },
    });
  }

  //切换岗位筛选类型
  changeStaSelectType(){
    var type = this.state.staSelectType;
    let t = this;
    if(type == "0"){//切换为按组织架构选择
      var url = t.getFetchUrl("org", "", "", false, false);
      fetch(url,{
        method: "GET",
        mode: "cors",
        headers: {
          'Accept': 'application/json, text/plain, */*',
          'Content-Type': 'application/x-www-form-urlencoded'
        }
      }).then((response) => response.json()).then((result) => {//alert(JSON.stringify(result));
        //console.log("fetch请求数据"+JSON.stringify(result));
        var orgList = result.data;
        if(orgList==null || orgList==undefined){
          orgList = [];
        }
        t.setState({
          stationOrgList: orgList,
          stationList: [],
          selectStaNum: 0,
          navStationList: [{"id": "0", "orgName": "全部", "checkAll": false}],
          staSelectType: "1",
          stationName: "",
          isShowNav: false,
          isShowCheckAll: false
        },()=>{t.instance.update(t.getContent())});
      }).catch((error) => {
        //console.log("错误："+error);
      });
    }else{//切换为按岗位选择
      var checkType = this.props.checkType;
      var isShowCheckAll = true;
      if(checkType == "radio"){
        isShowCheckAll = false;
      }
      var url = t.getFetchUrl("station", "", this.state.stationName, false, true);
      fetch(url,{
        method: "GET",
        mode: "cors",
        headers: {
          'Accept': 'application/json, text/plain, */*',
          'Content-Type': 'application/x-www-form-urlencoded'
        }
      }).then((response) => response.json()).then((result) => {//alert(JSON.stringify(result));
        var stationList = result.data;
        var selectStaNum = 0, noUseStationNum = 0;
        var navList = [{"id": "0", "orgName": "全部", "checkAll": false}];
        if(stationList==null || stationList==undefined){
          stationList = [];
        }else{
          var selectStations = t.state.selectedList.selectStations;
          selectStaNum = t.dataIsChecked(stationList, selectStations, selectStaNum);
          noUseStationNum = t.countNoUseNum(stationList);
          if(stationList.length == noUseStationNum){//全部不可选
            navList[0].canUse = "0";
          }else{
            navList[0].canUse = "1";
            if(selectStaNum == (stationList.length-noUseStationNum)){
              navList[0].checkAll = true;
            }
          }
        }
        t.setState({
          stationOrgList: [],
          stationList: stationList,
          selectStaNum: selectStaNum,
          noUseStationNum: noUseStationNum,
          navStationList: navList,
          staSelectType: "0",
          stationName: "",
          isShowNav: false,
          isShowCheckAll: isShowCheckAll
        },()=>{t.instance.update(t.getContent())});
      }).catch((error) => {
        alert("错误："+error);
      });
    }
  }

  //修改获取的常用数据选中状态
  commonDataChecked(data){
    var checkType = this.props.checkType;
    var selectCommonNum = 0;
    if(!(checkType=="radio" && selectCommonNum==1)){
      var selectUsers = this.state.selectedList.selectUsers;
      selectCommonNum += this.commonDataIsChecked(data, selectUsers, selectCommonNum, checkType, "user");
    }
    if(!(checkType=="radio" && selectCommonNum==1)){
      var selectOrgs = this.state.selectedList.selectOrgs;
      selectCommonNum += this.commonDataIsChecked(data, selectOrgs, selectCommonNum, checkType, "org");
    }
    if(!(checkType=="radio" && selectCommonNum==1)) {
      var selectRoles = this.state.selectedList.selectRoles;
      selectCommonNum += this.commonDataIsChecked(data, selectRoles, selectCommonNum, checkType, "role");
    }
    if(!(checkType=="radio" && selectCommonNum==1)) {
      var selectStations = this.state.selectedList.selectStations;
      selectCommonNum += this.commonDataIsChecked(data, selectStations, selectCommonNum, checkType, "station");
    }
    if(!(checkType=="radio" && selectCommonNum==1)) {
      var selectGroups = this.state.selectedList.selectGroups;
      selectCommonNum += this.commonDataIsChecked(data, selectGroups, selectCommonNum, checkType, "group");
    }
    return selectCommonNum;
  }
  commonDataIsChecked(data, selectData, selectNum, checkType, code){
    for(var j=0; j<data.length; j++){
      if(data[j].scopeType == code){
        data[j].checked = false;
        for(var i = 0; i<selectData.length; i++) {
          if(selectData[i].id == data[j].scopeValue){
            data[j].checked = true;
            if(checkType == "radio"){
              selectNum = 1;
            }else{
              selectNum ++;
              break;
            }
          }
        }
      }
    }
    return selectNum;
  }

  //获取数据
  getSelectData(){
    let code = this.getRealCode().split(",");
    var type = code[0];
    if(type == "user"){
      type = "org";
    }
    let t = this;
    if(type == "common"){
      let checkType = this.props.checkType;
      var commonUsedData = [];
      var commonUsedPropsData = this.props.commonUsedData;
      var selectCommonNum = 0;
      var commonCheckAll = false;
      var commonDefaultData = [];
      if(commonUsedPropsData!=null && commonUsedPropsData!=undefined && commonUsedPropsData.length>0){
        for(var i=0; i<commonUsedPropsData.length; i++){
          var data = {
            scopeType: commonUsedPropsData[i].scopeType,
            scopeName: commonUsedPropsData[i].scopeName,
            scopeValue: commonUsedPropsData[i].scopeValue,
            checked: commonUsedPropsData[i].checked,
            imageId: commonUsedPropsData[i].imageId
          };
          commonUsedData.push(data);
        }
        selectCommonNum = t.commonDataChecked(commonUsedData);
        if(selectCommonNum == commonUsedData.length){
          commonCheckAll = true;
        }
        for(var i=0; i<commonUsedData.length; i++){
          var data = {
            scopeType: commonUsedData[i].scopeType,
            scopeName: commonUsedData[i].scopeName,
            scopeValue: commonUsedData[i].scopeValue,
            checked: commonUsedData[i].checked,
            imageId: commonUsedData[i].imageId
          };
          commonDefaultData.push(data);
        }
      }
      var isShowCheckAll = true;
      if(checkType == "radio"){
        isShowCheckAll = false;
      }
      t.setState({
        commonUsedData: commonUsedData,
        commonDefaultData: commonDefaultData,
        selectCommonNum: selectCommonNum,
        isShowCheckAll: isShowCheckAll,
        commonCheckAll: commonCheckAll,
        activeKey: type
      },()=>{t.instance.update(t.getContent())});
    }else if(type == "user"){
      var url = t.getFetchUrl("org", "", "", false, false);
      fetch(url,{
        method: "GET",
        mode: "cors",
        headers: {
          'Accept': 'application/json, text/plain, */*',
          'Content-Type': 'application/x-www-form-urlencoded'
        }
      }).then(response => response.json()).then(result => {//alert(JSON.stringify(result));
        //console.log("fetch请求数据"+JSON.stringify(result));
         var orgList = result.data;
        if(orgList==null || orgList==undefined){
          orgList = [];
        }
        t.setState({
          userOrgList: orgList,
          activeKey: type
        },()=>{t.instance.update(t.getContent())});
      }).catch(function (e) {
        alert("错误："+e);
      });
    }else if(type == "org"){
      var checkType = this.props.checkType;
      var isShowCheckAll = true;
      if(checkType == "radio"){
        isShowCheckAll = false;
      }
      var url = t.getFetchUrl("org", "", "", false, true);
      fetch(url,{
        method: "GET",
        mode: "cors",
        headers: {
          'Accept': 'application/json, text/plain, */*',
          'Content-Type': 'application/x-www-form-urlencoded'
        }
      }).then((response) => response.json()).then((result) => {//alert(JSON.stringify(result));
        //console.log("fetch请求数据"+JSON.stringify(result));
        var orgList = result.data;
        var selectOrgNum = 0, noUseOrgNum = 0;
        var navList = [{"id": "0", "orgName": "全部", "checkAll": false}];
        if(orgList==null || orgList==undefined){
          orgList = [];
        }else{
          var selectOrgs = t.state.selectedList.selectOrgs;
          selectOrgNum = t.dataIsChecked(orgList, selectOrgs, selectOrgNum);
          noUseOrgNum = t.countNoUseNum(orgList);//不可选组织数量
          if(orgList.length == noUseOrgNum){//全部不可选
            navList[0].canUse = "0";
          }else{
            navList[0].canUse = "1";
            if(selectOrgNum == (orgList.length-noUseOrgNum)){
              navList[0].checkAll = true;
            }
          }
        }
        t.setState({
          orgList: orgList,
          orgUserList: [],
          selectOrgNum: selectOrgNum,
          noUseOrgNum: noUseOrgNum,
          selectOrgUserNum: 0,
          navOrgList: navList,
          isShowCheckAll: isShowCheckAll,
          activeKey: type
        },()=>{t.instance.update(t.getContent())});
      }).catch((error) => {
        alert("错误："+error);
      });
    }else if(type == "role"){
      var checkType = this.props.checkType;
      var isShowCheckAll = true;
      if(checkType == "radio"){
        isShowCheckAll = false;
      }
      var url = t.getFetchUrl("role", "", "", false, true);
      fetch(url,{
        method: "GET",
        mode: "cors",
        headers: {
          'Accept': 'application/json, text/plain, */*',
          'Content-Type': 'application/x-www-form-urlencoded'
        }
      }).then((response) => response.json()).then((result) => {//alert(JSON.stringify(result));
        //console.log("fetch请求数据"+JSON.stringify(result));
        var roleList = result.data;
        var selectRoleNum = 0;
        var roleCheckAll = false;
        if(roleList==null || roleList==undefined){
          roleList = [];
        }else{
          var selectRoles = t.state.selectedList.selectRoles;
          selectRoleNum = t.dataIsChecked(roleList, selectRoles, selectRoleNum);
          if(selectRoleNum == roleList.length){
            roleCheckAll = true;
          }
        }
        t.setState({
          roleList: roleList,
          selectRoleNum: selectRoleNum,
          roleCheckAll: roleCheckAll,
          isShowCheckAll: isShowCheckAll,
          activeKey: type
        },()=>{t.instance.update(t.getContent())});
      }).catch((error) => {
        alert("错误："+error);
      });
    }else if(type == "station"){
      var checkType = this.props.checkType;
      var isShowCheckAll = true;
      if(checkType == "radio"){
        isShowCheckAll = false;
      }
      var url = t.getFetchUrl("station", "", "", false, true);
      fetch(url,{
        method: "GET",
        mode: "cors",
        headers: {
          'Accept': 'application/json, text/plain, */*',
          'Content-Type': 'application/x-www-form-urlencoded'
        }
      }).then((response) => response.json()).then((result) => {//alert(JSON.stringify(result));
        //console.log("fetch请求数据"+JSON.stringify(result));
        var stationList = result.data;
        var selectStaNum = 0, noUseStationNum = 0;
        var navList = [{"id": "0", "orgName": "全部", "checkAll": false}];
        if(stationList==null || stationList==undefined){
          stationList = [];
        }else{
          var selectStations = t.state.selectedList.selectStations;
          selectStaNum = t.dataIsChecked(stationList, selectStations, selectStaNum);
          noUseStationNum = t.countNoUseNum(stationList);//不可选岗位数量
          if(stationList.length == noUseStationNum){//全部不可选
            navList[0].canUse = "0";
          }else{
            navList[0].canUse = "1";
            if(selectStaNum == (stationList.length-noUseStationNum)){
              navList[0].checkAll = true;
            }
          }
        }
        t.setState({
          stationList: stationList,
          selectStaNum: selectStaNum,
          noUseStationNum: noUseStationNum,
          navStationList: navList,
          isShowCheckAll: isShowCheckAll,
          activeKey: type
        },()=>{t.instance.update(t.getContent())});
      }).catch((error) => {
        alert("错误："+error);
      });
    }else if(type == "group"){
      var checkType = this.props.checkType;
      var isShowCheckAll = true;
      if(checkType == "radio"){
        isShowCheckAll = false;
      }
      var url = t.getFetchUrl("group", "", "", false, true);
      fetch(url,{
        method: "GET",
        mode: "cors",
        headers: {
          'Accept': 'application/json, text/plain, */*',
          'Content-Type': 'application/x-www-form-urlencoded'
        }
      }).then((response) => response.json()).then((result) => {//alert(JSON.stringify(result));
        //console.log("fetch请求数据"+JSON.stringify(result));
        var groupList = result.data.groupList;
        var selectGroupNum = 0, noUseGroupNum = 0;
        var navList = [{"id": "0", "groupName": "全部", "checkAll": false}];
        if(groupList==null || groupList==undefined){
          groupList = [];
        }else{
          var selectGroups = t.state.selectedList.selectGroups;
          selectGroupNum = t.dataIsChecked(groupList, selectGroups, selectGroupNum);
          noUseGroupNum = t.countNoUseNum(groupList);//不可选群组数量
          if(groupList.length == noUseGroupNum){//全部不可选
            navList[0].canUse = "0";
          }else{
            navList[0].canUse = "1";
            if(selectGroupNum == (groupList.length-noUseGroupNum)){
              navList[0].checkAll = true;
            }
          }
        }
        t.setState({
          groupList: groupList,
          groupUserList: [],
          selectGroupNum: selectGroupNum,
          noUseGroupNum: noUseGroupNum,
          selectGroupUserNum: 0,
          navGroupList: navList,
          isShowCheckAll: isShowCheckAll,
          activeKey: type
        },()=>{t.instance.update(t.getContent())});
      }).catch((error) => {
        alert("错误："+error);
      });
    }
  }

  countNoUseNum(list){
    var noUseNum = 0;
    if(list!=null && list.length>0){
      for(var i=0; i<list.length; i++){
        if(list[i].canUse == "0"){
          noUseNum ++;
        }
      }
    }
    return noUseNum;
  }

  //切换tab
  handleTabChange(obj) {
    var isShowNav = false;
    var isShowCheckAll = false;
    var checkType = this.props.checkType;
    let t = this;
    var chooseType = this.getChooseType();
    if(obj.activeKey == "common"){
      var commonUsedData = t.state.commonUsedData;
      var selectCommonNum = 0;
      var commonCheckAll = false;
      if(commonUsedData!=null && commonUsedData!=undefined && commonUsedData.length>0){
        selectCommonNum = t.commonDataChecked(commonUsedData);
        if(selectCommonNum == commonUsedData.length){
          commonCheckAll = true;
        }
      }
      var isShowCheckAll = true;
      if(checkType == "radio"){
        isShowCheckAll = false;
      }
      t.setState({
        selectCommonNum: selectCommonNum,
        isShowCheckAll: isShowCheckAll,
        commonCheckAll: commonCheckAll,
        isShowNav: false,
        activeKey: obj.activeKey
      },()=>{t.instance.update(t.getContent())});
    }else if(obj.activeKey == "user"){
      var userList = t.state.userList;
      var navUserList = t.state.navUserList;
      var userName = t.state.userName;
      if((userList==null || userList.length<=0) && (navUserList==null || navUserList.length<=0) && userName==""){
        var url = t.getFetchUrl("org", "", "", false, false);
        fetch(url,{
          method: "GET",
          mode: "cors",
          headers: {
            'Accept': 'application/json, text/plain, */*',
            'Content-Type': 'application/x-www-form-urlencoded'
          }
        }).then((response) => response.json()).then((result) => {//alert(JSON.stringify(result));
          //console.log("fetch请求数据"+JSON.stringify(result));
          var orgList = result.data;
          var selectOrgNum = 0;
          var navList = [];
          if(orgList==null || orgList==undefined){
            orgList = [];
          }
          t.setState({
            userOrgList: orgList,
            userList: [],
            selectUserNum: 0,
            navUserList: navList,
            isShowNav: false,
            isShowCheckAll: isShowCheckAll,
            activeKey: obj.active
          },()=>{t.instance.update(t.getContent())});
        }).catch((error) => {
          alert("错误：" + error);
          //console.log("错误："+error);
        });
      }else{
        var navList = this.state.navUserList;
        if(navList!=null && navList.length>=1 && checkType!="radio"){
          isShowCheckAll = true;
          isShowNav = true;
        }
        t.setState({
          isShowNav: isShowNav,
          isShowCheckAll: isShowCheckAll,
          activeKey: obj.active
        },()=>{t.instance.update(t.getContent())});
      }
    }else if(obj.active == "org"){
      var isShowCheckAll = true;
      if(checkType == "radio"){
        isShowCheckAll = false;
      }
      var orgList = this.state.orgList;
      var navOrgList = this.state.navOrgList;
      var orgName = this.state.orgName;
      if((orgList==null || orgList.length<=0) && (navOrgList==null || navOrgList.length<=0) && orgName==""){
        var url = t.getFetchUrl("org", "", "", false, true);
        fetch(url,{
          method: "GET",
          mode: "cors",
          headers: {
            'Accept': 'application/json, text/plain, */*',
            'Content-Type': 'application/x-www-form-urlencoded'
          }
        }).then((response) => response.json()).then((result) => {//alert(JSON.stringify(result));
          //console.log("fetch请求数据"+JSON.stringify(result));
          var orgList = result.data;
          var selectOrgNum = 0, noUseOrgNum = 0;
          var checkAllOrg = false
          var navList = [{"id": "0", "orgName": "全部", "checkAll": false}];
          if(orgList==null || orgList==undefined){
            orgList = [];
          }else{
            var selectOrgs = t.state.selectedList.selectOrgs;
            selectOrgNum = t.dataIsChecked(orgList, selectOrgs, selectOrgNum);
            noUseOrgNum = t.countNoUseNum(orgList);
            if(orgList.length == noUseOrgNum){//全部不可选
              navList[0].canUse = "0";
            }else{
              navList[0].canUse = "1";
              if(selectOrgNum == (orgList.length-noUseOrgNum)){
                checkAllOrg = true;
              }
            }
          }
          t.setState({
            orgList: orgList,
            orgUserList: [],
            selectOrgNum: selectOrgNum,
            noUseOrgNum: noUseOrgNum,
            selectOrgUserNum: 0,
            navOrgList: navList,
            isShowNav: false,
            isShowCheckAll: isShowCheckAll,
            activeKey: obj.active
          },()=>{t.instance.update(t.getContent())});
        }).catch((error) => {
          alert("错误：" + error);
          //console.log("错误："+error);
        });
      }else{
        var navList = this.state.navOrgList;
        if(navList!=null && navList.length>1){
          isShowNav = true;
        }
        var selectOrgNum = 0, noUseOrgNum = 0;
        var orgList = this.state.orgList;
        var userList = this.state.orgUserList;
        var checkAllOrg = true;
        if(orgList==null || orgList==undefined){
          orgList = [];
        }else{
          if(chooseType.indexOf("userNotOrg") < 0) {
            var selectOrgs = t.state.selectedList.selectOrgs;
            selectOrgNum = t.dataIsChecked(orgList, selectOrgs, selectOrgNum);
            noUseOrgNum = t.countNoUseNum(orgList);
            if (selectOrgNum != (orgList.length - noUseOrgNum)) {
              checkAllOrg = false;
            }
          }
        }
        var selectUserNum = 0;
        var checkAllUser = true;
        if(userList==null || userList==undefined){
          userList = [];
        }else{
          if(chooseType.indexOf("userNotOrg")>=0 || chooseType.indexOf("userAndOrg")>=0) {
            var selectUsers = this.state.selectedList.selectUsers;
            selectUserNum = this.dataIsChecked(userList, selectUsers, selectUserNum);
            if (selectUserNum != userList.length) {
              checkAllUser = false;
            }
          }
        }
        if (orgList.length==noUseOrgNum && userList.length==0) {//全部不可选
          navList[navList.length - 1].canUse = "0";
        } else {
          navList[navList.length - 1].canUse = "1";
        }
        if(checkAllUser && checkAllOrg){
          navList[navList.length-1].checkAll = true;
        }
        t.setState({
          orgList: orgList,
          orgUserList: userList,
          selectOrgNum: selectOrgNum,
          noUseOrgNum: noUseOrgNum,
          selectOrgUserNum: selectUserNum,
          navOrgList: navList,
          isShowNav: isShowNav,
          isShowCheckAll: isShowCheckAll,
          activeKey: obj.active
        },()=>{t.instance.update(t.getContent())});
      }
    }else if(obj.active == "role"){
      var isShowCheckAll = true;
      if(checkType == "radio"){
        isShowCheckAll = false;
      }
      var roleList = this.state.roleList;
      var roleName = this.state.roleName;
      if((roleList==null || roleList.length<=0) && roleName==""){
        var url = t.getFetchUrl("role", "", "", false, true);
        fetch(url,{
          method: "GET",
          mode: "cors",
          headers: {
            'Accept': 'application/json, text/plain, */*',
            'Content-Type': 'application/x-www-form-urlencoded'
          }
        }).then((response) => response.json()).then((result) => {//alert(JSON.stringify(result));
          //console.log("fetch请求数据"+JSON.stringify(result));
          var roleList = result.data;
          var selectRoleNum = 0;
          var roleCheckAll = false;
          if(roleList==null || roleList==undefined){
            roleList = [];
          }else{
            var selectRoles = t.state.selectedList.selectRoles;
            selectRoleNum = t.dataIsChecked(roleList, selectRoles, selectRoleNum);
            if(selectRoleNum == roleList.length){
              roleCheckAll = true;
            }
          }
          t.setState({
            roleList: roleList,
            selectRoleNum: selectRoleNum,
            roleCheckAll: roleCheckAll,
            isShowNav: false,
            isShowCheckAll: isShowCheckAll,
            activeKey: obj.active
          },()=>{t.instance.update(t.getContent())});
        }).catch((error) => {
          alert("错误："+error);
        });
      }else{
        t.setState({
          isShowNav: false,
          isShowCheckAll: isShowCheckAll,
          activeKey: obj.active
        },()=>{t.instance.update(t.getContent())});
      }
    }else if(obj.active == "station"){
      var stationList = this.state.stationList;
      var navStationList = this.state.navStationList;
      var stationName = this.state.stationName;
      if((stationList==null || stationList.length<=0) && (navStationList==null || navStationList.length<=0) && stationName==""){
        var isShowCheckAll = true;
        if(checkType == "radio"){
          isShowCheckAll = false;
        }
        var url = t.getFetchUrl("station", "", "", false, true);
        fetch(url,{
          method: "GET",
          mode: "cors",
          headers: {
            'Accept': 'application/json, text/plain, */*',
            'Content-Type': 'application/x-www-form-urlencoded'
          }
        }).then((response) => response.json()).then((result) => {//alert(JSON.stringify(result));
          //console.log("fetch请求数据"+JSON.stringify(result));
          var stationList = result.data;
          var selectStaNum = 0, noUseStationNum = 0;
          var navList = [{"id": "0", "orgName": "全部", "checkAll": false}];
          if(stationList==null || stationList==undefined){
            stationList = [];
          }else{
            var selectStations = t.state.selectedList.selectStations;
            selectStaNum = t.dataIsChecked(stationList, selectStations, selectStaNum);
            noUseStationNum = t.countNoUseNum(stationList);
            if(stationList.length == noUseStationNum){//全部不可选
              navList[0].canUse = "0";
            }else{
              navList[0].canUse = "1";
              if(selectStaNum == (stationList.length-noUseStationNum)){
                navList[0].checkAll = true;
              }
            }
          }
          t.setState({
            stationList: stationList,
            stationOrgList: [],
            selectStaNum: selectStaNum,
            noUseStationNum: noUseStationNum,
            navStationList: navList,
            isShowNav: false,
            isShowCheckAll: isShowCheckAll,
            activeKey: obj.active
          },()=>{t.instance.update(t.getContent())});
        }).catch((error) => {
          alert("错误："+error);
        });
      }else{
        var staSelectType = t.state.staSelectType;
        var navList = this.state.navStationList;
        if(staSelectType == "0"){
          if(checkType != "radio"){
            isShowCheckAll = true;
          }
          if(navList!=null && navList.length>1){
            isShowNav = true;
          }else{
            isShowNav = false;
          }
        }else{
          if(navList!=null && navList.length>=1){
            isShowNav = true;
            if(checkType != "radio"){
              isShowCheckAll = true;
            }
          }
        }
        if(t.state.stationName != "" && checkType != "radio"){
          isShowCheckAll = true;
        }
        t.setState({
          isShowNav: isShowNav,
          isShowCheckAll: isShowCheckAll,
          activeKey: obj.active
        },()=>{t.instance.update(t.getContent())});
      }
    }else if(obj.active == "group"){
      var isShowCheckAll = true;
      if(checkType == "radio"){
        isShowCheckAll = false;
      }
      var groupList = this.state.groupList;
      var navGroupList = this.state.navGroupList;
      var groupName = this.state.groupName;
      if((groupList==null || groupList.length<=0) && (navGroupList=null || navGroupList.length<=0) && groupName==""){
        var url = t.getFetchUrl("group", "", "", false, true);
        fetch(url,{
          method: "GET",
          mode: "cors",
          headers: {
            'Accept': 'application/json, text/plain, */*',
            'Content-Type': 'application/x-www-form-urlencoded'
          }
        }).then((response) => response.json()).then((result) => {//alert(JSON.stringify(result));
          //console.log("fetch请求数据"+JSON.stringify(result));
          var groupList = result.data.groupList;
          var selectGroupNum = 0, noUseGroupNum = 0;
          var navList = [{"id": "0", "orgName": "全部", "checkAll": false}];
          if(groupList==null || groupList==undefined){
            groupList = [];
          }else{
            var selectGroups = t.state.selectedList.selectGroups;
            selectGroupNum = t.dataIsChecked(groupList, selectGroups, selectGroupNum);
            noUseGroupNum = t.countNoUseNum(groupList);
            if(groupList.length == noUseGroupNum){//全部不可选
              navList[0].canUse = "0";
            }else{
              navList[0].canUse = "1";
              if(selectGroupNum == (groupList.length-noUseGroupNum)){
                navList[0].checkAll = true;
              }
            }
          }
          t.setState({
            groupList: groupList,
            groupUserList: [],
            selectGroupNum: selectGroupNum,
            noUseGroupNum: noUseGroupNum,
            selectGroupUserNum: 0,
            navGroupList: navList,
            isShowNav: false,
            isShowCheckAll: isShowCheckAll,
            activeKey: obj.active
          },()=>{t.instance.update(t.getContent())});
        }).catch((error) => {
          alert("错误："+error);
        });
      }else{
        var navList = this.state.navGroupList;
        if(navList!=null && navList.length>1){
          isShowNav = true;
        }
        var selectGroupNum = 0, noUseGroupNum = 0, selectGroupUserNum = 0;
        var groupList = this.state.groupList;
        var checkAllGroup = true;
        if(groupList==null || groupList==undefined){
          groupList = [];
        }else{
          if(chooseType.indexOf("userNotGroup") < 0) {
            var selectGroups = t.state.selectedList.selectGroups;
            selectGroupNum = t.dataIsChecked(groupList, selectGroups, selectGroupNum);
            noUseGroupNum = t.countNoUseNum(groupList);
            if (selectGroupNum != (groupList.length - noUseGroupNum)) {
              checkAllGroup = false;
            }
          }
        }
        var userList = this.state.groupUserList;
        var selectUserNum = 0;
        var checkAllUser = true;
        if(userList==null || userList==undefined){
          userList = [];
        }else{
          if(chooseType.indexOf("userNotGroup")>=0 || chooseType.indexOf("userAndGroup")>=0) {
            var selectUsers = t.state.selectedList.selectUsers;
            selectUserNum = t.dataIsChecked(userList, selectUsers, selectUserNum);
            if (selectUserNum != userList.length) {
              checkAllUser = false;
            }
          }
        }
        if (groupList.length==noUseGroupNum && userList.length==0) {//全部不可选
          navList[navList.length - 1].canUse = "0";
        } else {
          navList[navList.length - 1].canUse = "1";
        }
        if(checkAllGroup && checkAllUser){
          navList[navList.length-1].checkAll = true;
        }
        t.setState({
          groupList: groupList,
          groupUserList: userList,
          selectGroupNum: selectGroupNum,
          noUseGroupNum: noUseGroupNum,
          selectGroupUserNum: selectUserNum,
          navGroupList: navList,
          isShowNav: isShowNav,
          isShowCheckAll: isShowCheckAll,
          activeKey: obj.active
        },()=>{t.instance.update(t.getContent())});
      }
    }
  }

  //搜索
  memberSearch(value, type, searchType){
    var checkType = this.props.checkType;
    var chooseType = this.getChooseType();
    var isShowCheckAll = true;
    if(checkType == "radio"){
      isShowCheckAll = false;
    }
    value = value.replace(/\s/g,"");
	if(isEmojiCharacter(value)){
      Toast.show({
        type: 'error',
        content: '请输入正确字符搜索',
        onHide: function () {}
      });
      return false;
    }
    var t = this;
    if(searchType=="0" && value==""){
      return;
    }else{
      if(type == "common"){
        var commonSearchData = [];
        var commonUsedData = t.state.commonDefaultData;
        if(searchType=="0" && value!=""){
          if(commonUsedData!=null && commonUsedData!=undefined && commonUsedData.length>0){
            for(var i=0; i<commonUsedData.length; i++){
              if(commonUsedData[i].scopeName.indexOf(value) >= 0){
                commonSearchData.push(commonUsedData[i]);
              }
            }
          }
        }else{
          if(commonUsedData!=null && commonUsedData!=undefined && commonUsedData.length>0){
            for(var i=0; i<commonUsedData.length; i++){
              commonSearchData.push(commonUsedData[i]);
            }
          }
        }

        var selectCommonNum = 0;
        if(commonSearchData.length > 0){
          selectCommonNum = t.commonDataChecked(commonSearchData);
        }
        var commonCheckAll = false;
        if(commonSearchData!=null && commonSearchData!=undefined && selectCommonNum==commonSearchData.length){
          commonCheckAll = true;
        }
        t.setState({
          commonUsedData: commonSearchData,
          selectCommonNum: selectCommonNum,
          isShowCheckAll: isShowCheckAll,
          commonCheckAll: commonCheckAll,
          commonName: value,
          isShowNav: false,
          activeKey: type
        },()=>{t.instance.update(t.getContent())});
      }else if(type == "user"){
        var url = "";
        if(searchType=="0" && value!=""){//搜索
          url = t.getFetchUrl("user", "", value, false, true);
        }else{
          url = t.getFetchUrl("org", "", "", false, false);
        }
        fetch(url,{
          method: "GET",
          mode: "cors",
          headers: {
            'Accept': 'application/json, text/plain, */*',
            'Content-Type': 'application/x-www-form-urlencoded'
          }
        }).then(response => response.json()).then(result => {//alert(JSON.stringify(result));
          //console.log("fetch请求数据"+JSON.stringify(result));
          var orgList = [], userList = [];
          if(searchType == "0"){
            userList = result.data;
          }else{
            orgList = result.data;
          }
          if(orgList==null || orgList==undefined){
            orgList = [];
          }
          var selectUserNum = 0;
          var navList = [];
          if(searchType == "0"){
            navList = [{"id": "0", "userName": "全部", "checkAll": false}];
          }
          if(userList==null || userList==undefined){
            userList = [];
          }else{
            var selectUsers = t.state.selectedList.selectUsers;
            selectUserNum = t.dataIsChecked(userList, selectUsers, selectUserNum);
            if(selectUserNum==userList.length && searchType=="0"){
              navList[0].checkAll = true;
            }
          }
          t.setState({
            userOrgList: orgList,
            userList: userList,
            selectUserNum: selectUserNum,
            userName: value,
            navUserList: navList,
            isShowNav: false,
            isShowCheckAll: isShowCheckAll
          },()=>{t.instance.update(t.getContent())});
        }).catch(function (e) {
          alert("错误："+e);
        });
      }else if(type == "org"){
        var url = "";
        if(searchType=="0" && value!="") {//搜索
          url = t.getFetchUrl("org", "", value, true, true);
        }else{
          url = t.getFetchUrl("org", "", value, false, true);
        }
        fetch(url,{
          method: "GET",
          mode: "cors",
          headers: {
            'Accept': 'application/json, text/plain, */*',
            'Content-Type': 'application/x-www-form-urlencoded'
          }
        }).then((response) => response.json()).then((result) => {//alert(JSON.stringify(result));
          //console.log("fetch请求数据"+JSON.stringify(result));
          var orgList = result.data.orgList;
          var userList = result.data.userList;
          if(orgList==undefined && userList==undefined){
            orgList = result.data;
          }
          var selectOrgNum = 0, noUseOrgNum = 0;
          var navList = [{"id": "0", "orgName": "全部", "checkAll": false}];
          var checkAllOrg = true;
          if(orgList==null || orgList==undefined || (searchType=="0" && chooseType.indexOf("userNotOrg")>=0)){
            orgList = [];
          }else{
            if(chooseType.indexOf("userNotOrg") < 0) {
              var selectOrgs = t.state.selectedList.selectOrgs;
              selectOrgNum = t.dataIsChecked(orgList, selectOrgs, selectOrgNum);
              noUseOrgNum = t.countNoUseNum(orgList);
              if (selectOrgNum != (orgList.length - noUseOrgNum)) {
                checkAllOrg = false;
              }
            }
          }
          var selectUserNum = 0;
          var checkAllUser = true;
          if(userList==null || userList==undefined){
            userList = [];
          }else{
            if(chooseType.indexOf("userNotOrg")>=0 || chooseType.indexOf("userAndOrg")>=0) {
              var selectUsers = t.state.selectedList.selectUsers;
              selectUserNum = t.dataIsChecked(userList, selectUsers, selectUserNum);
              if (selectUserNum != userList.length) {
                checkAllUser = false;
              }
            }
          }
          if (orgList.length==noUseOrgNum && userList.length==0) {//全部不可选
            navList[0].canUse = "0";
          } else {
            navList[0].canUse = "1";
          }
          if(checkAllUser && checkAllOrg){
            navList[0].checkAll = true;
          }
          t.setState({
            orgList: orgList,
            orgUserList: userList,
            selectOrgNum: selectOrgNum,
            noUseOrgNum: noUseOrgNum,
            selectOrgUserNum: selectUserNum,
            orgName: value,
            navOrgList: navList,
            isShowNav: false,
            isShowCheckAll: isShowCheckAll
          },()=>{t.instance.update(t.getContent())});
        }).catch((error) => {
          alert("错误："+error);
        });
      }else if(type == "role"){
        var url = t.getFetchUrl("role", "", value, false, true);
        fetch(url,{
          method: "GET",
          mode: "cors",
          headers: {
            'Accept': 'application/json, text/plain, */*',
            'Content-Type': 'application/x-www-form-urlencoded'
          }
        }).then((response) => response.json()).then((result) => {//alert(JSON.stringify(result));
          //console.log("fetch请求数据"+JSON.stringify(result));
          var roleList = result.data;
          var selectRoleNum = 0;
          var roleCheckAll = false;
          if(roleList==null || roleList==undefined){
            roleList = [];
          }else{
            var selectRoles = t.state.selectedList.selectRoles;
            selectRoleNum = t.dataIsChecked(roleList, selectRoles, selectRoleNum);
            if(selectRoleNum == roleList.length){
              roleCheckAll = true;
            }
          }
          t.setState({
            roleList: roleList,
            selectRoleNum: selectRoleNum,
            roleName: value,
            roleCheckAll: roleCheckAll,
            isShowNav: false,
            isShowCheckAll: isShowCheckAll
          },()=>{t.instance.update(t.getContent())});
        }).catch((error) => {
          alert("错误："+error);
        });
      }else if(type == "station"){
        var url = "";
        if(t.state.staSelectType=="1" && searchType!="0"){
          url = t.getFetchUrl("org", "", "", false, false);
        }else{
          url = t.getFetchUrl("station", "", value, false, true);
        }
        fetch(url,{
          method: "GET",
          mode: "cors",
          headers: {
            'Accept': 'application/json, text/plain, */*',
            'Content-Type': 'application/x-www-form-urlencoded'
          }
        }).then((response) => response.json()).then((result) => {//alert(JSON.stringify(result));
          //console.log("fetch请求数据"+JSON.stringify(result));
          var stationList = [], orgList = [], navList = [];
          var selectStaNum = 0, noUseStationNum = 0;
          if(t.state.staSelectType=="1" && searchType!="0"){
            orgList = result.data;
            if(orgList==null || orgList==undefined){
              orgList = [];
            }
          }else{
            stationList = result.data;
            navList = [{"id": "0", "orgName": "全部", "checkAll": false}];
            if(stationList==null || stationList==undefined){
              stationList = [];
            }else{
              var selectStations = t.state.selectedList.selectStations;
              selectStaNum = t.dataIsChecked(stationList, selectStations, selectStaNum);
              noUseStationNum = t.countNoUseNum(stationList);
              if(stationList.length == noUseStationNum){//全部不可选
                navList[0].canUse = "0";
              }else{
                navList[0].canUse = "1";
                if(selectStaNum == (stationList.length-noUseStationNum)){
                  navList[0].checkAll = true;
                }
              }
            }
          }
          t.setState({
            stationList: stationList,
            stationOrgList: orgList,
            selectStaNum: selectStaNum,
            noUseStationNum: noUseStationNum,
            stationName: value,
            navStationList: navList,
            isShowNav: false,
            isShowCheckAll: isShowCheckAll
          },()=>{t.instance.update(t.getContent())});
        }).catch((error) => {
          alert("错误："+error);
        });
      }else if(type == "group"){
        var url = "";
        if(searchType=="0" && value!=""){
          url = t.getFetchUrl("group", "", value, true, true);
        }else{
          url = t.getFetchUrl("group", "", value, false, true);
        }
        fetch(url,{
          method: "GET",
          mode: "cors",
          headers: {
            'Accept': 'application/json, text/plain, */*',
            'Content-Type': 'application/x-www-form-urlencoded'
          }
        }).then((response) => response.json()).then((result) => {//alert(JSON.stringify(result));
          //console.log("fetch请求数据"+JSON.stringify(result));
          var groupList = result.data.groupList;
          var selectGroupNum = 0, noUseGroupNum = 0;
          var checkAllGroup = true;
          var navList = [{"id": "0", "groupName": "全部", "checkAll": false}];
          if(groupList==null || groupList==undefined || (searchType=="0" && chooseType.indexOf("userNotGroup")>=0)){
            groupList = [];
          }else{
            if(chooseType.indexOf("userNotGroup") < 0) {
              var selectGroups = t.state.selectedList.selectGroups;
              selectGroupNum = t.dataIsChecked(groupList, selectGroups, selectGroupNum);
              noUseGroupNum = t.countNoUseNum(groupList);
              if (selectGroupNum != (groupList.length - noUseGroupNum)) {
                checkAllGroup = false;
              }
            }
          }
          var userList = result.data.userList;
          var selectUserNum = 0;
          var checkAllUser = true;
          if(userList==null || userList==undefined){
            userList = [];
          }else{
            if(chooseType.indexOf("userNotGroup")>=0 || chooseType.indexOf("userAndGroup")>=0) {
              var selectUsers = t.state.selectedList.selectUsers;
              selectUserNum = t.dataIsChecked(userList, selectUsers, selectUserNum);
              if (selectUserNum != userList.length) {
                checkAllUser = false;
              }
            }
          }
          if (groupList.length==noUseGroupNum && userList.length==0) {//全部不可选
            navList[0].canUse = "0";
          } else {
            navList[0].canUse = "1";
          }
          if(checkAllUser && checkAllGroup){
            navList[0].checkAll = true;
          }
          t.setState({
            groupList: groupList,
            groupUserList: userList,
            selectGroupNum: selectGroupNum,
            noUseGroupNum: noUseGroupNum,
            selectGroupUserNum: selectUserNum,
            groupName: value,
            navGroupList: navList,
            isShowNav: false,
            isShowCheckAll: isShowCheckAll
          },()=>{t.instance.update(t.getContent())});
        }).catch((error) => {
          alert("错误："+error);
        });
      }
    }
  }

  getContent() {
    let t = this;
    var isSelectShow = this.state.isSelectShow;
    var content = "";
    var selectedList = this.state.selectedList;
    var selectUsers = selectedList.selectUsers, selectOrgs = selectedList.selectOrgs,
      selectRoles = selectedList.selectRoles, selectStations = selectedList.selectStations,
      selectGroups = selectedList.selectGroups;

    var propsCode = this.getRealCode();
    if(propsCode==undefined || propsCode==null){
      propsCode = "user";
    }
    var selectCode = propsCode.split(",");
    var userIndex = -1, orgIndex = -1;
    for(var i=0; i<selectCode.length; i++){
      if(selectCode[i] == "user"){
        userIndex = i;
      }else if(selectCode[i] == "org"){
        orgIndex = i;
      }
    }
    if(userIndex>=0 && orgIndex>=0){//存在user,org
      selectCode.splice(userIndex, 1);
    }else if(userIndex>=0 && orgIndex<0){//存在user,不存在org
      selectCode[userIndex] = "org";
    }
    var chooseType = this.getChooseType();
    var orgTitle = "组织";
    if(chooseType.indexOf("userNotOrg") >= 0){
      orgTitle = "用户";
    }
    var navList = this.state.navUserList;
    var commonUsedData = this.state.commonUsedData;
    var currentNav = "";
    var currentCheckAll = false;
    var checkAllCanUse = "";
    var activeKey = this.state.activeKey;
    if(activeKey == "user"){
      navList = this.state.navUserList;
    }else if(activeKey == "org"){
      navList = this.state.navOrgList;
    }else if(activeKey == "station"){
      navList = this.state.navStationList;
    }else if(activeKey == "group"){
      navList = this.state.navGroupList;
    }
    if(navList!=null && navList.length>0){
      currentNav = navList[navList.length-1].id;
      currentCheckAll = navList[navList.length-1].checkAll;
      checkAllCanUse = navList[navList.length-1].canUse;
    }

    const props = {
      placeholder: "请输入",
      locale: 'zh_CN',
      instantSearch: false,
      hasHistory: false,
      searchDelay: 450,
      onEnter: () => { console.log('enter'); },
      onChange: (value) => {
        console.log(`Typing>>${value}`);
      }
    };

    content = (
      <div className="t-W100 select-member-div-class">
        <div style={{position: "relative", height: `${this.state.winHeight}`}} className={(isSelectShow && selectUsers.length<=0 && selectOrgs.length<=0 && selectRoles.length<=0 && selectStations.length<=0 && selectGroups.length<=0)?"scrollHeight":"t-DN"}>
          <div className="nodata-wrapper">
            <VBox vAlign="center" hAlign="center" className="nodata">
              <Box>
                <div>
                  <img src={nodataIcon} alt="" style={{width: 68 + 'px'}} />
                </div>
              </Box>
              <Box className="t-FCc">
                暂时没有数据
              </Box>
            </VBox>
          </div>
          <div className="t-bottom-fixed no-border t-BCf">
            <Button type="primary" onClick={()=>{t.handleSelectClick(false)}}>返回</Button>
          </div>
        </div>
        <div className={isSelectShow && !(selectUsers.length<=0 && selectOrgs.length<=0 && selectRoles.length<=0 && selectStations.length<=0 && selectGroups.length<=0)?"":"t-DN"}>
          <div style={{overflow:"auto", height: `${this.state.winHeight}`}} className="t-PB168">
            <HBox vAlign="center" className={selectUsers.length>0?"t-PL16 t-PR16 t-FS14":"t-DN"}>
              <Box className="t-PT10 t-PB10" flex={1}>已选用户:{selectUsers.length}</Box>
              <Box className={selectUsers.length>0 ? "t-FCred":"t-DN"} onClick={()=>{t.clearItemMember()}}>清空</Box>
            </HBox>
            <HBox className={selectUsers.length>0?"dd-appwrap":"t-DN"}>
              {selectUsers.map(function(item,i){
                return (
                  <VBox className="dd-app dd-app-avatar" vAlign="center" hAlign="center" onClick={()=>{t.deleteItemMember(i,"user")}}>
                    <Box>
                      <Avatar filter={prevName => prevName} name={item.userName} src={item.imageId} defaultColor={'#8ccfec'} />
                    </Box>
                    <Box className="t-MT6 t-PL4 t-PR4 t-WB t-FAC t-omit t-LH1_4">{item.userName}</Box>
                    <Box className="dd-appbadge"><i className="iconfont icon-plus t-rotate-45"></i></Box>
                  </VBox>
                )})
              }
            </HBox>
            <HBox vAlign="center" className={selectOrgs.length>0?"t-PL16 t-PR16 t-FS14":"t-DN"}>
              <Box className="t-PT10 t-PB10" flex={1}>已选组织:{selectOrgs.length}</Box>
              <Box className={selectUsers.length<=0 ? "t-FCred":"t-DN"} onClick={()=>{t.clearItemMember()}}>清空</Box>
            </HBox>
            <HBox className={selectOrgs.length>0?"dd-appwrap":"t-DN"}>
              {selectOrgs.map(function(item,i){
                return(
                  <VBox className="dd-app dd-app-avatar" vAlign="center" hAlign="center" onClick={()=>{t.deleteItemMember(i,"org")}}>
                    <Box><div className="t-avatar t-WH40 t-LH40 t-BCoranger"><i className={item.orgType=='3'?"t-FS20 iconfont icon-organization t-FCf":"t-FS20 iconfont icon-mechanism t-FCf"}></i></div></Box>
                    <Box className="t-MT6 t-PL4 t-PR4 t-WB t-FAC t-omit t-LH1_4">{ item.orgName }</Box>
                    <Box className="dd-appbadge"><i className="iconfont icon-plus t-rotate-45"></i></Box>
                  </VBox>
                )})
              }
            </HBox>
            <HBox vAlign="center" className={selectRoles.length>0?"t-PL16 t-PR16 t-FS14":"t-DN"}>
              <Box className="t-PT10 t-PB10" flex={1}>已选角色:{selectRoles.length}</Box>
              <Box className={(selectUsers.length<=0&&selectOrgs.length<=0) ? "t-FCred":"t-DN"} onClick={()=>{t.clearItemMember()}}>清空</Box>
            </HBox>
            <HBox className={selectRoles.length>0?"dd-appwrap":"t-DN"}>
              {selectRoles.map(function(item,i){
                return(
                  <VBox className="dd-app dd-app-avatar" vAlign="center" hAlign="center" onClick={()=>{t.deleteItemMember(i,"role")}}>
                    <Box><div className="t-avatar t-WH40 t-LH40 t-BCgreen"><i className="t-FS20 iconfont icon-role t-FCf"></i></div></Box>
                    <Box className="t-MT6 t-PL4 t-PR4 t-WB t-FAC t-omit t-LH1_4">{ item.roleName }</Box>
                    <Box className="dd-appbadge"><i className="iconfont icon-plus t-rotate-45"></i></Box>
                  </VBox>
                )})
              }
            </HBox>
            <HBox vAlign="center" className={selectStations.length>0?"t-PL16 t-PR16 t-FS14":"t-DN"}>
              <Box className="t-PT10 t-PB10" flex={1}>已选岗位:{selectStations.length}</Box>
              <Box className={(selectUsers.length<=0&&selectOrgs.length<=0&&selectRoles.length<=0) ? "t-FCred":"t-DN"} onClick={()=>{t.clearItemMember()}}>清空</Box>
            </HBox>
            <HBox className={selectStations.length>0?"dd-appwrap":"t-DN"}>
              {selectStations.map(function(item,i){
                return(
                  <VBox className="dd-app dd-app-avatar" vAlign="center" hAlign="center" onClick={()=>{t.deleteItemMember(i,"station")}}>
                    <Box><div className="t-avatar t-WH40 t-LH40 t-BCoranger"><i className="t-FS20 iconfont icon-mine t-FCf"></i></div></Box>
                    <Box className="t-MT6 t-PL4 t-PR4 t-WB t-FAC t-omit t-LH1_4">{ item.stationName }</Box>
                    <Box className="dd-appbadge"><i className="iconfont icon-plus t-rotate-45"></i></Box>
                  </VBox>
                )})
              }
            </HBox>
            <HBox vAlign="center" className={selectGroups.length>0?"t-PL16 t-PR16 t-FS14":"t-DN"}>
              <Box className="t-PT10 t-PB10" flex={1}>已选群组:{selectGroups.length}</Box>
              <Box className={(selectUsers.length<=0&&selectOrgs.length<=0&&selectRoles.length<=0&&selectStations.length<=0) ? "t-FCred":"t-DN"} onClick={()=>{t.clearItemMember()}}>清空</Box>
            </HBox>
            <HBox className={selectGroups.length>0?"dd-appwrap":"t-DN"}>
              {selectGroups.map(function(item,i){
                return(
                  <VBox className="dd-app dd-app-avatar" vAlign="center" hAlign="center" onClick={()=>{t.deleteItemMember(i,"group")}}>
                    <Box><div className="t-avatar t-WH40 t-LH40 t-BCblue"><i className="t-FS20 iconfont icon-group t-FCf"></i></div></Box>
                    <Box className="t-MT6 t-PL4 t-PR4 t-WB t-FAC t-omit t-LH1_4">{ item.groupName }</Box>
                    <Box className="dd-appbadge"><i className="iconfont icon-plus t-rotate-45"></i></Box>
                  </VBox>
                )})
              }
            </HBox>
          </div>
          <div className="t-bottom-fixed no-border t-BCf">
            <Button type="primary" onClick={()=>{t.handleSelectClick(false)}}>返回</Button>
          </div>
        </div>
        <div className={!isSelectShow?"":"t-DN"}>
          <Tab activeKey={this.state.activeKey} onChange={this.handleTabChange.bind(this)}>{
            selectCode.map(function(code, i){
              if(code == "common"){
                var tabContent = "";
                tabContent = (
                  <div style={{overflow:"auto", height: `${t.state.tabHeight}`}} className="t-PB68 dd-top-border scrollHeight t-PR">
                    { (commonUsedData==null || commonUsedData==undefined || commonUsedData.length<=0) && t.state.activeKey=="common" ?
                      <div className="nodata-wrapper">
                        <VBox vAlign="center" hAlign="center" className="nodata">
                          <Box>
                            <div>
                              <img src={nodataIcon} alt="" style={{width: 68 + 'px'}} />
                            </div>
                          </Box>
                          <Box className="t-FCc">
                            暂时没有数据
                          </Box>
                        </VBox>
                      </div>
                      :
                      commonUsedData.map(function(item, index){
                        var scopeType = item.scopeType;
                        var showHtml = "";
                        if(scopeType == "user"){
                          showHtml = (
                            <Box className="t-PT10 t-PB10 t-PL10 t-PR6">
                              <Avatar filter={prevName => prevName} name={item.scopeName} src={item.imageId} defaultColor={'#F6BF26'}/>
                            </Box>
                          );
                        }else if(scopeType == "org"){
                          showHtml = (
                            <Box className="t-PT10 t-PB10 t-PR6"><i className="iconfont icon-organization t-FCd t-FS20"></i></Box>
                          );
                        }else if(scopeType == "role"){
                          showHtml = (
                            <Box className="t-PT10 t-PB10 t-PL6 t-PR6"><i className="iconfont icon-role t-FCd t-FS20"></i></Box>
                          );
                        }else if(scopeType == "station"){
                          showHtml = (
                            <Box className="t-PT10 t-PB10 t-PR6"><i className="iconfont icon-mine t-FCd t-FS20"></i></Box>
                          );
                        }else if(scopeType == "group"){
                          showHtml = (
                            <Box className="t-PT10 t-PB10 t-PR6"><i className="iconfont icon-group t-FCd t-FS20"></i></Box>
                          );
                        }
                        return(
                          <div className="t-PL16 t-PR16 dd-bottom-border t-BCf" onClick={()=>{t.checkItemMember(index,"common")}}>
                            <HBox vAlign="center">
                              <HBox>
                                <div className={item.checked?'t-checkbox-field-icon-list':'un-checked t-checkbox-field-icon-list'}>
                                  <i className="iconfont icon-checked t-FCf t-FS14"></i>
                                </div>
                              </HBox>
                              {showHtml}
                              <Box flex={1} className="t-FS16 t-PL4 t-PR10 t-omit">{item.scopeName}</Box>
                            </HBox>
                          </div>
                        )
                      })}
                  </div>
                );
                return (
                  <Tab.Item title="常用" key="common" className={selectCode.indexOf("common")>=0 ? "" : "t-DN"}>
                    <SearchBar {...props} onSearch={(value)=>{t.memberSearch(value,"common","0")}} onExit={()=>{t.memberSearch("","common","1")}}>
                    </SearchBar>
                    {tabContent}
                  </Tab.Item>
                );
              }else if(code == "org"){
                var isShowCheckAll = t.state.isShowCheckAll;
                if(isShowCheckAll){
                  if(chooseType.indexOf("userNotOrg")<0 && t.state.orgList.length>0){
                    isShowCheckAll = true;
                  }else if((chooseType.indexOf("userAndOrg")>=0 || chooseType.indexOf("userNotOrg")>=0) && t.state.orgUserList.length>0){
                    isShowCheckAll = true;
                  }else{
                    isShowCheckAll = false;
                  }
                }
                var tabContent = (
                  <div style={{overflow:"auto", height: `${t.state.tabHeight}`}} className="t-PB68 dd-top-border scrollHeight t-PR">
                    <div className={isShowCheckAll ? "":"t-DN"}>
                      <div className="t-PL16 t-PR16 t-LH3 dd-bottom-border t-BCf" onClick={()=>{t.checkAllMember("org");}}>
                        <HBox vAlign="center">
                          <HBox>
                            <div className={checkAllCanUse=='0'?'t-checkbox-field-icon-list disabled':currentCheckAll?'t-checkbox-field-icon-list':'un-checked t-checkbox-field-icon-list'}>
                              <i className="iconfont icon-checked t-FCf t-FS14"></i>
                            </div>
                          </HBox>
                          <Box flex={1} className="t-ML10">全选</Box>
                        </HBox>
                      </div>
                    </div>
                    <div className={(t.state.orgName=="" && t.state.isShowNav)?"t-BCf7 t-OFA t-WSN dd-bottom-border":"t-DN"} >
                      {navList.map(function(item, index){
                        if(index == 0){
                          return (
                            <div className="t-PL16 t-LH42 t-FCddblue t-DIB" onClick={()=>{t.handleNavClick("0", "org", "");}}>全部</div>
                          );
                        }else{
                          var nameHtml = "";
                          if(index == navList.length-1){
                            nameHtml = (<div className="t-FC9 t-DIB">{item.orgName}</div>);
                          }else{
                            nameHtml = (<div className="t-FC9 t-DIB t-FCddblue" onClick={()=>{t.handleNavClick(item.id, "org", "");}}>{item.orgName}</div>);
                          }
                          return (
                            <div className="t-DIB">
                              <div className="t-PL10 t-PR10 t-FCc t-DIB">></div>
                              { nameHtml }
                            </div>
                          );
                        }
                      })}
                    </div>
                    {t.state.orgList.length<=0 && t.state.orgUserList.length<=0 && t.state.activeKey=="org" ?
                      <div className="nodata-wrapper">
                        <VBox vAlign="center" hAlign="center" className="nodata">
                          <Box>
                            <div>
                              <img src={nodataIcon} alt="" style={{width: 68 + 'px'}} />
                            </div>
                          </Box>
                          <Box className="t-FCc">
                            暂时没有数据
                          </Box>
                        </VBox>
                      </div> : ""
                    }
                    {t.state.orgList.map(function(org, index){
                      if(chooseType.indexOf("userNotOrg") < 0){
                        return (
                          <HBox vAlign="center" className="dd-bottom-border t-BCf">
                            <HBox className="t-PL16 t-PR10" onClick={() => {
                              t.checkItemMember(index, "org")
                            }}>
                              <div
                                className={org.canUse == '0' ? 't-checkbox-field-icon-list disabled' : org.checked ? 't-checkbox-field-icon-list' : 'un-checked t-checkbox-field-icon-list'}>
                                <i className="iconfont icon-checked t-FCf t-FS14"></i>
                              </div>
                            </HBox>
                            <Box className="t-PT10 t-PB10 t-PR6"><i className={org.orgType=='3'?"iconfont icon-organization t-FCd t-FS20":"iconfont icon-mechanism t-FCd t-FS20"}></i></Box>
                            <Box flex={1} className="t-FS16 t-PL4 t-PR10 t-omit">{org.orgName}</Box>
                            <Box className={t.state.orgName == "" ? "t-PR16" : "t-DN"} onClick={() => { t.handleOrgShow(org.id); }}><i className="iconfont icon-arrow-up t-rotate-90 t-FCc"></i></Box>
                          </HBox>
                        );
                      }else{
                        return (
                          <HBox vAlign="center" className="dd-bottom-border t-BCf" onClick={()=>{t.handleOrgShow(org.id);}}>
                            <Box className="t-PT12 t-PB12 t-PL16 t-PR6"><i className={org.orgType=='3'?"iconfont icon-organization t-FCd t-FS20":"iconfont icon-mechanism t-FCd t-FS20"}></i></Box>
                            <Box flex={1} className="t-FS16 t-PL4 t-PR10 t-omit">{org.orgName}</Box>
                            <Box className="t-PR16"><i className="iconfont icon-arrow-up t-rotate-90 t-FCc"></i></Box>
                          </HBox>
                        );
                      }
                    })}
                    {chooseType.indexOf("userAndOrg")>=0 || chooseType.indexOf("userNotOrg")>=0 ?
                      t.state.orgUserList.map(function(user, index){
                        return (
                          <HBox vAlign="center" className="dd-bottom-border t-BCf" onClick={()=>{t.checkItemMember(index,"orgUser")}}>
                            <HBox  className="t-PL16 t-PR10">
                              <div className={user.canUse=='0'?'t-checkbox-field-icon-list disabled':user.checked?'t-checkbox-field-icon-list':'un-checked t-checkbox-field-icon-list'}>
                                <i className="iconfont icon-checked t-FCf t-FS14"></i>
                              </div>
                            </HBox>
                            <Box className="t-PT10 t-PB10 t-PL10 t-PR6">
                              <Avatar filter={prevName => prevName} name={user.userName} src={user.imageId} defaultColor={'#F6BF26'}/>
                            </Box>
                            <Box flex={1} className="t-FS16 t-PL4 t-PR10">{user.userName}
                              <div className="t-FS13 t-PR10" style={{color:'#33333373'}}>{user.orgNamePath}</div>
                            </Box>
                          </HBox>
                        )
                      }) : ""
                    }
                  </div>
                );
                return (
                  <Tab.Item title={orgTitle} key="org" className={selectCode.indexOf("org")>=0 ? "" : "t-DN"}>
                    <SearchBar {...props} onSearch={(value)=>{t.memberSearch(value,"org","0")}} onExit={()=>{t.memberSearch("","org","1")}}>
                    </SearchBar>
                    {tabContent}
                  </Tab.Item>
                );
              }else if(code == "role"){
                var tabContent = (
                  <div style={{overflow:"auto", height: `${t.state.tabHeight}`}} className="t-PB68 dd-top-border scrollHeight t-PR">
                    <div className={(t.state.isShowCheckAll&&t.state.roleList.length>0)?"":"t-DN"}>
                      <div className="t-PL16 t-PR16 t-LH3 dd-bottom-border t-BCf" onClick={()=>{t.checkAllMember("role");}}>
                        <HBox vAlign="center">
                          <HBox>
                            <div className={t.state.roleCheckAll?'t-checkbox-field-icon-list':'un-checked t-checkbox-field-icon-list'}>
                              <i className="iconfont icon-checked t-FCf t-FS14"></i>
                            </div>
                          </HBox>
                          <Box flex={1} className="t-ML10">全选</Box>
                        </HBox>
                      </div>
                    </div>
                    {t.state.roleList.length<=0 && t.state.activeKey=="role" ?
                      <div className="nodata-wrapper">
                        <VBox vAlign="center" hAlign="center" className="nodata">
                          <Box>
                            <div>
                              <img src={nodataIcon} alt="" style={{width: 68 + 'px'}} />
                            </div>
                          </Box>
                          <Box className="t-FCc">
                            暂时没有数据
                          </Box>
                        </VBox>
                      </div>
                      :
                      t.state.roleList.map(function(role, index){
                        return(
                          <div className="t-PL16 t-PR10 dd-bottom-border t-BCf" onClick={()=>{t.checkItemMember(index,"role")}}>
                            <HBox vAlign="center">
                              <HBox>
                                <div className={role.checked?'t-checkbox-field-icon-list':'un-checked t-checkbox-field-icon-list'}>
                                  <i className="iconfont icon-checked t-FCf t-FS14"></i>
                                </div>
                              </HBox>
                              <Box className="t-PT10 t-PB10 t-PL6 t-PR6"><i className="iconfont icon-role t-FCd t-FS20"></i></Box>
                              <Box flex={1} className="t-FS16 t-PL4 t-PR10 t-omit">{role.roleName}</Box>
                            </HBox>
                          </div>
                        )
                      })}
                  </div>
                );
                return (
                  <Tab.Item title="角色" key="role" className={selectCode.indexOf("role")>=0 ? "" : "t-DN"}>
                    <SearchBar {...props} onSearch={(value)=>{t.memberSearch(value,"role","0")}} onExit={()=>{t.memberSearch("","role","1")}}>
                    </SearchBar>
                    {tabContent}
                  </Tab.Item>
                );
              }else if(code == "station"){
                var tabContent = (
                  <div style={{overflow:"auto", height: `${t.state.tabHeight}`}} className="t-PB68 dd-top-border scrollHeight t-PR t-BCf">
                    <HBox vAlign="center" className="dd-bottom-border">
                      <Box className="t-PL16 t-PR10 t-LH42 t-FC9" flex={1}>{t.state.staSelectType=="0"?"按岗位选择":"按组织架构选择"}</Box>
                      <Box className="t-PL16 t-PR16" onClick={()=>{t.changeStaSelectType();}}><i className="iconfont icon-change t-FCc t-FS18 t-PR6"></i></Box>
                    </HBox>
                    <div className={(t.state.isShowCheckAll&&t.state.stationList.length>0)?"":"t-DN"}>
                      <div className="t-PL16 t-PR16 t-LH3 dd-bottom-border t-BCf" onClick={()=>{t.checkAllMember("station");}}>
                        <HBox vAlign="center">
                          <HBox>
                            <div className={checkAllCanUse=='0'?'t-checkbox-field-icon-list disabled':currentCheckAll?'t-checkbox-field-icon-list':'un-checked t-checkbox-field-icon-list'}>
                              <i className="iconfont icon-checked t-FCf t-FS14"></i>
                            </div>
                          </HBox>
                          <Box flex={1} className="t-ML10">全选</Box>
                        </HBox>
                      </div>
                    </div>
                    <div className={(t.state.stationName=="" && t.state.isShowNav)?"t-BCf7 t-OFA t-WSN dd-bottom-border":"t-DN"} >
                      {navList.map(function(item, index){
                        if(index == 0){
                          return (
                            <div className="t-PL16 t-LH42 t-FCddblue t-DIB" onClick={()=>{t.handleNavClick("0", "station", "");}}>全部</div>
                          );
                        }else{
                          var nameHtml = "";
                          if(index == navList.length-1){
                            nameHtml = (<div className="t-FC9 t-DIB">{item.type=="org"?item.orgName:item.stationName}</div>);
                          }else{
                            nameHtml = (<div className="t-FC9 t-DIB t-FCddblue" onClick={()=>{t.handleNavClick(item.id, "station", item.type);}}>{item.type=="org"?item.orgName:item.stationName}</div>);
                          }
                          return (
                            <div className="t-DIB">
                              <div className="t-PL10 t-PR10 t-FCc t-DIB">></div>
                              { nameHtml }
                            </div>
                          );
                        }
                      })}
                    </div>
                    {t.state.stationOrgList.length<=0 && t.state.stationList.length<=0 && t.state.activeKey=="station" ?
                      <div className="nodata-wrapper">
                        <VBox vAlign="center" hAlign="center" className="nodata">
                          <Box>
                            <div>
                              <img src={nodataIcon} alt="" style={{width: 68 + 'px'}} />
                            </div>
                          </Box>
                          <Box className="t-FCc">
                            暂时没有数据
                          </Box>
                        </VBox>
                      </div> : ""
                    }
                    {t.state.stationOrgList.map(function(org, index){
                      return (
                        <HBox vAlign="center" className="dd-bottom-border t-BCf" onClick={()=>{t.handleStationShow(org.id, "org");}}>
                          <Box className="t-PT12 t-PB12 t-PL16 t-PR6"><i className={org.orgType=='3'?"iconfont icon-organization t-FCd t-FS20":"iconfont icon-mechanism t-FCd t-FS20"}></i></Box>
                          <Box flex={1} className="t-FS16 t-PL4 t-PR10 t-omit">{org.orgName}</Box>
                          <Box className="t-PR16"><i className="iconfont icon-arrow-up t-rotate-90 t-FCc"></i></Box>
                        </HBox>
                      )
                    })}
                    {t.state.stationList.map(function(station, index){
                      return(
                        <HBox vAlign="center" className="dd-bottom-border t-BCf">
                          <HBox  className="t-PL16 t-PR10" onClick={()=>{t.checkItemMember(index,"station")}}>
                            <div className={station.canUse=='0'?'t-checkbox-field-icon-list disabled':station.checked?'t-checkbox-field-icon-list':'un-checked t-checkbox-field-icon-list'}>
                              <i className="iconfont icon-checked t-FCf t-FS14"></i>
                            </div>
                          </HBox>
                          <Box className="t-PT10 t-PB10 t-PR6"><i className="iconfont icon-mine t-FCd t-FS20"></i></Box>
                          <Box flex={1} className="t-FS16 t-PL4 t-PR10 t-omit">{station.stationName}</Box>
                          <Box className={t.state.stationName==""?"t-PR16":"t-DN"} onClick={()=>{t.handleStationShow(station.id, "station");}}><i className="iconfont icon-arrow-up t-rotate-90 t-FCc"></i></Box>
                        </HBox>
                      )
                    })}
                  </div>
                );
                return (
                  <Tab.Item title="岗位" key="station" className={selectCode.indexOf("station")>=0 ? "" : "t-DN"}>
                    <SearchBar {...props} onSearch={(value)=>{t.memberSearch(value,"station","0")}} onExit={()=>{t.memberSearch("","station","1")}}>
                    </SearchBar>
                    {tabContent}
                  </Tab.Item>
                );
              }else if(code == "group"){
                var isShowCheckAll = t.state.isShowCheckAll;
                if(isShowCheckAll){
                  if(chooseType.indexOf("userNotGroup")<0 && t.state.groupList.length>0){
                    isShowCheckAll = true;
                  }else if((chooseType.indexOf("userAndGroup")>=0 || chooseType.indexOf("userNotGroup")>=0) && t.state.groupUserList.length>0){
                    isShowCheckAll = true;
                  }else{
                    isShowCheckAll = false;
                  }
                }
                var tabContent = (
                  <div style={{overflow:"auto", height: `${t.state.tabHeight}`}} className="t-PB68 dd-top-border scrollHeight t-PR t-BCf">
                    <div className={isShowCheckAll ? "":"t-DN"}>
                      <div className="t-PL16 t-PR16 t-LH3 dd-bottom-border t-BCf" onClick={()=>{t.checkAllMember("group");}}>
                        <HBox vAlign="center">
                          <HBox>
                            <div className={checkAllCanUse=='0'?'t-checkbox-field-icon-list disabled':currentCheckAll?'t-checkbox-field-icon-list':'un-checked t-checkbox-field-icon-list'}>
                              <i className="iconfont icon-checked t-FCf t-FS14"></i>
                            </div>
                          </HBox>
                          <Box flex={1} className="t-ML10">全选</Box>
                        </HBox>
                      </div>
                    </div>
                    <div className={(t.state.groupName=="" && t.state.isShowNav)?"t-BCf7 t-OFA t-WSN dd-bottom-border":"t-DN"} >
                      {navList.map(function(item, index){
                        if(index == 0){
                          return (
                            <div className="t-PL16 t-LH42 t-FCddblue t-DIB" onClick={()=>{t.handleNavClick("0", "group", "");}}>全部</div>
                          );
                        }else{
                          var nameHtml = "";
                          if(index == navList.length-1){
                            nameHtml = (<div className="t-FC9 t-DIB">{item.groupName}</div>);
                          }else{
                            nameHtml = (<div className="t-FC9 t-DIB t-FCddblue" onClick={()=>{t.handleNavClick(item.id, "group", "");}}>{item.groupName}</div>);
                          }
                          return (
                            <div className="t-DIB">
                              <div className="t-PL10 t-PR10 t-FCc t-DIB">></div>
                              { nameHtml }
                            </div>
                          );
                        }
                      })}
                    </div>
                    {t.state.groupList.length<=0 && t.state.groupUserList.length<=0 && t.state.activeKey=="group" ?
                      <div className="nodata-wrapper">
                        <VBox vAlign="center" hAlign="center" className="nodata">
                          <Box>
                            <div>
                              <img src={nodataIcon} alt="" style={{width: 68 + 'px'}} />
                            </div>
                          </Box>
                          <Box className="t-FCc">
                            暂时没有数据
                          </Box>
                        </VBox>
                      </div> : ""
                    }
                    {t.state.groupList.map(function(group, index){
                      if(chooseType.indexOf("userNotGroup") < 0){
                        return(
                          <HBox vAlign="center" className="dd-bottom-border t-BCf">
                            {chooseType.indexOf("userNotGroup") < 0 ?
                              <HBox  className="t-PL16 t-PR10" onClick={()=>{t.checkItemMember(index,"group")}}>
                                <div className={group.canUse=='0'?'t-checkbox-field-icon-list disabled':group.checked?'t-checkbox-field-icon-list':'un-checked t-checkbox-field-icon-list'}>
                                  <i className="iconfont icon-checked t-FCf t-FS14"></i>
                                </div>
                              </HBox> : ""
                            }
                            <Box className="t-PT10 t-PB10 t-PR6"><i className="iconfont icon-group t-FCd t-FS20"></i></Box>
                            <Box flex={1} className="t-FS16 t-PL4 t-PR10 t-omit">{group.groupName}</Box>
                            <Box className={t.state.groupName==""?"t-PR16":"t-DN"} onClick={()=>{t.handleGroupShow(group.id);}}><i className="iconfont icon-arrow-up t-rotate-90 t-FCc"></i></Box>
                          </HBox>
                        )
                      }else{
                        return (
                          <HBox vAlign="center" className="dd-bottom-border t-BCf" onClick={()=>{t.handleGroupShow(group.id);}}>
                            <Box className="t-PT12 t-PB12 t-PL16 t-PR6"><i className="iconfont icon-group t-FCd t-FS20"></i></Box>
                            <Box flex={1} className="t-FS16 t-PL4 t-PR10 t-omit">{group.groupName}</Box>
                            <Box className="t-PR16"><i className="iconfont icon-arrow-up t-rotate-90 t-FCc"></i></Box>
                          </HBox>
                        );
                      }
                    })}
                    {chooseType.indexOf("userAndGroup")>=0 || chooseType.indexOf("userNotGroup")>=0 ?
                      t.state.groupUserList.map(function(user, index){
                        return (
                          <HBox vAlign="center" className="dd-bottom-border t-BCf" onClick={()=>{t.checkItemMember(index,"groupUser")}}>
                            <HBox  className="t-PL16 t-PR10">
                              <div className={user.canUse=='0'?'t-checkbox-field-icon-list disabled':user.checked?'t-checkbox-field-icon-list':'un-checked t-checkbox-field-icon-list'}>
                                <i className="iconfont icon-checked t-FCf t-FS14"></i>
                              </div>
                            </HBox>
                            <Box className="t-PT10 t-PB10 t-PL10 t-PR6">
                              <Avatar filter={prevName => prevName} name={user.userName} src={user.imageId} defaultColor={'#F6BF26'}/>
                            </Box>
                            <Box flex={1} className="t-FS16 t-PL4 t-PR10">{user.userName}
                              <div className="t-FS13 t-PR10" style={{color:'#33333373'}} >{user.orgNamePath}</div>
                            </Box>
                          </HBox>
                        )
                      }) : ""
                    }
                  </div>
                );
                return (
                  <Tab.Item title="群组" key="group" className={selectCode.indexOf("group")>=0 ? "" : "t-DN"}>
                    <SearchBar {...props} onSearch={(value)=>{t.memberSearch(value,"group","0")}} onExit={()=>{t.memberSearch("","group","1")}}>
                    </SearchBar>
                    {tabContent}
                  </Tab.Item>
                );
              }else if(code == "user"){
                var tabContent = (
                  <div style={{overflow:"auto", height: `${t.state.tabHeight}`}} className="t-PB68 dd-top-border scrollHeight">
                    <div className={(t.state.isShowCheckAll&&t.state.userList.length>0)?"":"t-DN"}>
                      <div className="t-PL16 t-PR16 t-LH3 dd-bottom-border t-BCf" onClick={()=>{t.checkAllMember("user");}}>
                        <HBox vAlign="center">
                          <HBox>
                            <div className={currentCheckAll?'t-checkbox-field-icon-list':'un-checked t-checkbox-field-icon-list'}>
                              <i className="iconfont icon-checked t-FCf t-FS14 t-LH"></i>
                            </div>
                          </HBox>
                          <Box flex={1} className="t-ML10">全选</Box>
                        </HBox>
                      </div>
                    </div>
                    <div className={(t.state.userName=="" && t.state.isShowNav)?"t-BCf7 t-OFA t-WSN dd-bottom-border":"t-DN"}>
                      <div className="t-PL16 t-LH42 t-FCddblue t-DIB" onClick={()=>{t.handleNavClick("0", "user", "");}}>全部</div>
                      {navList.map(function(item, index){
                        var nameHtml = "";
                        if(index == navList.length-1){
                          nameHtml = (<div className="t-FC9 t-DIB">{item.orgName}</div>);
                        }else{
                          nameHtml = (<div className="t-FC9 t-DIB t-FCddblue" onClick={()=>{t.handleNavClick(item.id, "user", "");}}>{item.orgName}</div>);
                        }
                        return (
                          <div className="t-DIB">
                            <div className="t-PL10 t-PR10 t-FCc t-DIB">></div>
                            { nameHtml }
                          </div>
                        );
                      })}
                    </div>
                    {t.state.userOrgList.map(function(org, index){
                      return (
                        <HBox vAlign="center" className="dd-bottom-border" onClick={()=>{t.handleUserShow(org.id);}}>
                          <Box className="t-PT12 t-PB12 t-PL16 t-PR6"><i className={org.orgType=='3'?"iconfont icon-organization t-FCd t-FS20":"iconfont icon-mechanism t-FCd t-FS20"}></i></Box>
                          <Box flex={1} className="t-FS16 t-PL4 t-PR10 t-omit">{org.orgName}</Box>
                          <Box className="t-PR16"><i className="iconfont icon-arrow-up t-rotate-90 t-FCc"></i></Box>
                        </HBox>
                      )
                    })}
                    {t.state.userList.map(function(user, index){
                      return(
                        <div className="t-PL16 t-PR16 dd-bottom-border" onClick={()=>{t.checkItemMember(index,"user")}}>
                          <HBox vAlign="center">
                            <HBox>
                              <div className={user.checked?'t-checkbox-field-icon-list':'un-checked t-checkbox-field-icon-list'}>
                                <i className="iconfont icon-checked t-FCf t-FS14"></i>
                              </div>
                            </HBox>
                            <Box className="t-PT10 t-PB10 t-PL10 t-PR6">
                              <Avatar filter={prevName => prevName} name={user.userName} src={user.imageId} defaultColor={'#F6BF26'}/>
                            </Box>
                            <Box flex={1} className="t-FS16 t-PL4 t-PR10">{user.userName}
                              <div className="t-FS13 t-PR10" style={{color:'#33333373'}} >{user.orgNamePath}</div>
                            </Box>
                          </HBox>
                        </div>
                      )
                    })}
                  </div>
                );
                return (
                  <Tab.Item title="用户" key="user" className={selectCode.indexOf("user")>=0 ? "" : "t-DN"}>
                    <SearchBar {...props} onSearch={(value)=>{t.memberSearch(value,"user","0")}} onExit={()=>{t.memberSearch("","user","1")}}>
                    </SearchBar>
                    {tabContent}
                  </Tab.Item>
                );
              }
            })
          }</Tab>
          <HBox vAlign="center" className="t-P16 t-PT10 t-PB10 t-BCf dd-top-border">
            <Box flex={1} className="t-FS16 t-FCddblue" onClick={()=>{t.handleSelectClick(true)}}>
              <span>已选:</span><span>{t.state.total}</span>
            </Box>
            <Box className="t-MR4">
              <Button type="secondary" size="small" display="inline" onClick={()=>{t.handleClick("0")}}>取消</Button>
            </Box>
            <Box>
              <Button type="primary" size="small" display="inline" onClick={()=>{t.handleClick("1")}}>确定</Button>
            </Box>
          </HBox>
        </div>
      </div>
    );
    return content;
  }

  selectListToScopeList(selectedList){
    var selectUsers = selectValue.selectUsers;
    var selectOrgs = selectValue.selectOrgs;
    var selectRoles = selectValue.selectRoles;
    var selectStations = selectValue.selectStations;
    var selectGroups = selectValue.selectGroups;
    
    var value = [];
    for(var i=0; i<selectUsers.length;i++){
      var scope = {
        "scopeType": "user",
        "scopeName": selectUsers[i].userName,
        "scopeValue": selectUsers[i].id
      };
      value.push(scope);
    }
    for(var i=0; i<selectOrgs.length;i++){
      var scope = {
        "scopeType": "org",
        "scopeName": selectOrgs[i].orgName,
        "scopeValue": selectOrgs[i].id,
		"orgType": selectOrgs[i].orgType
      };
      value.push(scope);
    }
    for(var i=0; i<selectRoles.length;i++){
      var scope = {
        "scopeType": "role",
        "scopeName": selectRoles[i].roleName,
        "scopeValue": selectRoles[i].id
      };
      value.push(scope);
    }
    for(var i=0; i<selectStations.length;i++){
      var scope = {
        "scopeType": "station",
        "scopeName": selectStations[i].stationName,
        "scopeValue": selectStations[i].id
      };
      value.push(scope);
    }
    for(var i=0; i<selectGroups.length;i++){
      var scope = {
        "scopeType": "group",
        "scopeName": selectGroups[i].groupName,
        "scopeValue": selectGroups[i].id
      };
      value.push(scope);
    }
    return value;
  }

  cancelOrBack(){
    var defaultList = this.state.defaultList;
    var scopeList = [];
    for(var i=0; i<defaultList.length; i++){
      scopeList.push(defaultList[i]);
    }
    var commonUsedData = [];
    var commonDefaultData = this.state.commonDefaultData;
    if(commonDefaultData!=null && commonDefaultData!=undefined && commonDefaultData!=""){
      for(var i=0; i<commonDefaultData.length; i++){
        commonUsedData.push(commonDefaultData[i]);
      }
    }
    var selectedList = this.scopeListToSelectList(scopeList, null);
    var total = scopeList.length;
    this.setState({
      scopeList: scopeList,
      selectedList: selectedList,
      commonUsedData: commonUsedData,
      userOrgList: [],
      userList: [],
      orgList: [],
      orgUserList: [],
      roleList: [],
      stationOrgList: [],
      stationList: [],
      groupList: [],
      groupUserList: [],
      selectCommonNum: 0,
      selectUserNum: 0,
      selectOrgNum: 0,
      selectOrgUserNum: 0,
      selectRoleNum: 0,
      selectStaNum: 0,
      selectGroupNum: 0,
      selectGroupUserNum: 0,
      noUseOrgNum: 0,//不可选部门数量
      noUseStationNum: 0,
      noUseGroupNum: 0,
      commonName: "",
      userName: "",
      orgName: "",
      roleName: "",
      stationName: "",
      groupName: "",
      commonCheckAll: false,
      navUserList: [],
      navOrgList: [],
      navStationList: [],
      roleCheckAll: false,
      navGroupList: [],
      staSelectType: "0",
      isShowNav: false,
      isShowCheckAll: false,
      total: total
    });
  }

  //确定取消
  handleClick(type){
    if(type == "0"){
      this.cancelOrBack();
    }else{
      var scopeList = this.state.scopeList;
      var defaultList = [], result = [];
      for(var i=0; i<scopeList.length; i++){
        defaultList.push(scopeList[i]);
        result.push(scopeList[i]);
      }
      var commonDefaultData = [];
      var commonUsedData = this.state.commonUsedData;
      if(commonUsedData!=null && commonUsedData!=undefined && commonUsedData!=""){
        for(var i=0; i<commonUsedData.length; i++){
          commonDefaultData.push(commonUsedData[i]);
        }
      }
      this.setState({
        defaultList: defaultList,
        commonDefaultData: commonDefaultData,
        userOrgList: [],
        userList: [],
        orgList: [],
        orgUserList: [],
        roleList: [],
        stationOrgList: [],
        stationList: [],
        groupList: [],
        groupUserList: [],
        selectCommonNum: 0,
        selectUserNum: 0,
        selectOrgNum: 0,
        selectOrgUserNum: 0,
        selectRoleNum: 0,
        selectStaNum: 0,
        selectGroupNum: 0,
        selectGroupUserNum: 0,
        noUseOrgNum: 0,//不可选部门数量
        noUseStationNum: 0,
        noUseGroupNum: 0,
        userName: "",
        orgName: "",
        commonName: "",
        roleName: "",
        stationName: "",
        groupName: "",
        commonCheckAll: false,
        navUserList: [],
        navOrgList: [],
        navStationList: [],
        roleCheckAll: false,
        navGroupList: [],
        staSelectType: "0",
        isShowNav: false,
        isShowCheckAll: false
      });
      this.props.onChange(result);
    }
    /*$("#App").css({
      "overflow":"auto",
      "height":"",
    });
    $(document).scrollTop(this.state.top);
    Popup.hide();*/
    history.back();
  }

  //删除
  deleteScopeMemeber(index){
    var scopeList = this.state.scopeList;
    var defaultList = this.state.defaultList;
    if(scopeList!=null && scopeList.length>0){
      var scope = scopeList[index];
      scopeList.splice(index, 1);
      defaultList.splice(index, 1);
      var selectValue = this.state.selectedList;
      if(scope.scopeType == "user"){
        var selectUsers = selectValue.selectUsers;
        for(var i=0; i<selectUsers.length; i++){
          if(selectUsers[i].id == scope.scopeValue){
            selectUsers.splice(i, 1);
            break;
          }
        }
        selectValue.selectUsers = selectUsers;
      }else if(scope.scopeType == "org"){
        var selectOrgs = selectValue.selectOrgs;
        for(var i=0; i<selectOrgs.length; i++){
          if(selectOrgs[i].id == scope.scopeValue){
            selectOrgs.splice(i, 1);
            break;
          }
        }
        selectValue.selectOrgs = selectOrgs;
      }else if(scope.scopeType == "role"){
        var selectRoles = selectValue.selectRoles;
        for(var i=0; i<selectRoles.length; i++){
          if(selectRoles[i].id == scope.scopeValue){
            selectRoles.splice(i, 1);
            break;
          }
        }
        selectValue.selectRoles = selectRoles;
      }else if(scope.scopeType == "station"){
        var selectStations = selectValue.selectStations;
        for(var i=0; i<selectStations.length; i++){
          if(selectStations[i].id == scope.scopeValue){
            selectStations.splice(i, 1);
            break;
          }
        }
        selectValue.selectStations = selectStations;
      }else if(scope.scopeType == "group"){
        var selectGroups = selectValue.selectGroups;
        for(var i=0; i<selectGroups.length; i++){
          if(selectGroups[i].id == scope.scopeValue){
            selectGroups.splice(i, 1);
            break;
          }
        }
        selectValue.selectGroups = selectGroups;
      }
      this.setState({
        defaultList: defaultList,
        scopeList: scopeList,
        selectedList: selectValue,
        total: this.state.total - 1
      });
      this.props.onChange(scopeList);
    }
  }

  clickAdd(){
    var readOnly = this.state.readOnly;
    let t = this;
    if(!readOnly){
      var tabHeight = parseInt(getScrollHigh(1, 1, 1));
      var top = $(window).scrollTop();
      this.setState({
        top: top,
        tabHeight: tabHeight+"px",
        historyStamp: `SelectMember.index_${Date.now()}`
      }, () => {
        window.history.pushState({
          SelectMember: t.state.historyStamp,
        }, '', utils.addUrlParam('SelectUser', Date.now()));
        window.addEventListener('popstate', t.listener, false);
      });
      $("#App").css({
        "overflow":"hidden",
        "height":"0",
      });
      this.instance = Popup.show(
        this.getContent(),
        {animationType:'slide-left'}
      );
      $(".select-member-div-class").parents(".t-popup").css({"left":"0", "background":"#f7f7f7"});
      this.getSelectData();
    }
  }
 
  render() {
    const t = this;

    /*var selectValue = this.state.selectedList;
    var selectUsers = selectValue.selectUsers;
    var selectOrgs = selectValue.selectOrgs;
    var selectRoles = selectValue.selectRoles;
    var selectStations = selectValue.selectStations;
    var selectGroups = selectValue.selectGroups;
    var selectText = selectValue.selectText;*/

    var required = this.state.required;
    var isDelete = this.state.isDelete;
    var readOnly = this.state.readOnly;

    var showType = this.state.showType;
    var placeholder = this.state.placeholder;
    var color = "t-FCgreyblue-tag";
    if(readOnly){
      placeholder = "";
      color = "t-FCc";
    }
    var memberHtml = "";
    if(showType == "button"){
      return (
        <div className='demo-section'>
          <div className="section-content">
            <Button type="primary" onClick={() => {this.clickAdd()}}>{this.state.label}</Button>
          </div>
        </div>
      );
    }else if(showType == "text"){
      var scopeList = t.state.scopeList;
      var selectText = "";
      for(var i=0; i<scopeList.length; i++){
        selectText += scopeList[i].scopeName+",";
      }
      if(selectText != ""){
        selectText = selectText.substring(0, selectText.length-1);
      }
      return (
        <HBox vAlign="center" className='t-FS16 t-PL16 t-PR16' onClick={() => {this.clickAdd()}}>
          <Box className={required ? 't-field-layout-h-label required' : 't-field-layout-h-label'}>{t.state.label}</Box>
          <HBox flex={1} >
            <Box flex={1} className={(selectText==""||selectText==null)?'t-FCtips t-PR10 t-omit':'t-PR10 t-omit'}>{(selectText==""||selectText==null)?placeholder:selectText}</Box>
            <Box className={readOnly?"t-DN":'t-PR4'}>
              <b className="iconfont icon-back t-rotate-180 t-FCc t-FS16 t-FS14"></b>
            </Box>
          </HBox>
        </HBox>
      );
    }else{
      return (
        <div>
          <div className="t-field-box t-FBH t-FBAC t-FBJ">
            <div className={required ? "t-field-layout-h-label t-FS16 required" : "t-field-layout-h-label t-FS16"}>{t.state.label}</div>
            <HBox flex={1} vAlign="center" onClick={() => {this.clickAdd();}}>
              <Box flex={1} className="t-FCtips t-FS16 t-PR10">
                <div className={t.state.scopeList==null||t.state.scopeList.length<=0?"t-omit":"t-DN"}>{placeholder}</div>
              </Box>
              <div ref="addnew" className="t-PR dd-file-add">
                <i className={readOnly?"t-DN":"iconfont icon-plus1 t-FS20"}></i>
              </div>
            </HBox>
          </div>
          <HBox className={t.state.scopeList==null || t.state.scopeList.length<=0 ? "t-fw t-FS12 t-FC9 t-PL14 t-PR14":"t-fw t-FS12 t-FC9 t-PL14 t-PR14 t-PB10"} vAlign="center">{
            t.state.scopeList.map(function(item,i){
              var className = "";
              if(item.scopeType == "user"){
                className = "iconfont icon-mine t-FS12 t-FL " + color;
              }else if(item.scopeType == "org"){
				if(item.orgType == "3"){
					className = "iconfont icon-organization t-FS12 t-FL " + color;
				}else{
					className = "iconfont icon-mechanism t-FS12 t-FL " + color;
				}
              }else if(item.scopeType == "role"){
                className = "iconfont icon-role t-FS12 t-FL " + color;
              }else if(item.scopeType == "station"){
                className = "iconfont icon-mine t-FS12 t-FL " + color;
              }else if(item.scopeType == "group"){
                className = "iconfont icon-group t-FS12 t-FL " + color;
              }
              return (
                <Box className={readOnly ? "t-BCf7 t-P4 t-PL6 t-PR6 t-M2 t-LH1_4 t-R3 t-PR" : "t-BCgreyblue-tag t-P4 t-PL6 t-PR6 t-M2 t-LH1_4 t-R3 t-PR"}>
                  <i className={className}></i>
                  <span className={readOnly ? "t-omit t-ML16 t-MR20":"t-FCgreyblue-tag t-omit t-ML16 t-MR20"}>{item.scopeName}</span>
                  <i className={(!readOnly && isDelete) ? ("iconfont icon-plus t-FS16 t-rotate-45 t-ML4 "+color+" t-PA"):"t-DN"} onClick={()=>{t.deleteScopeMemeber(i);}} style={{ right:"5px",top:"1px"}}></i>
                </Box>
              )})
            }
          </HBox>
        </div>
      );
    }
  }
}



